IClock Interface

Definition

Caution

For testing only. Use TimeProvider instead.

Abstraction over monotonic time providers (Environment.TickCount64, Stopwatch.GetTimestamp, as opposed to DateTime).

public interface IClock
[System.Obsolete("For testing only. Use TimeProvider instead.")]
public interface IClock
type IClock = interface
[<System.Obsolete("For testing only. Use TimeProvider instead.")>]
type IClock = interface
Public Interface IClock
Attributes

Properties

Name Description
TickCount

Gets a value that indicates the current tick count measured as milliseconds from an arbitrary reference time. The default implementation leverages TickCount64. This is generally more efficient than GetStopwatchTime(), but provides less precision.

Methods

Name Description
Delay(Int32, CancellationToken)

Creates a cancellable task that completes after a specified time interval. This is equivalent to Delay(Int32, CancellationToken), and facilitates unit tests that use virtual time.

Delay(TimeSpan, CancellationToken)

Creates a cancellable task that completes after a specified time interval. This is equivalent to Delay(TimeSpan, CancellationToken), and facilitates unit tests that use virtual time.

GetStopwatchTime()

Gets a precise time measurement using Stopwatch as the time source.

GetUtcNow()

Gets the current time in UTC as a DateTimeOffset.

Applies to