TimeProvider Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides an abstraction for time.
public ref class TimeProvider abstract
public abstract class TimeProvider
type TimeProvider = class
Public MustInherit Class TimeProvider
- Inheritance
-
TimeProvider
- Derived
Remarks
To make it easier to test time-dependent code, you can use FakeTimeProvider from the Microsoft.Extensions.Time.Testing package.
Constructors
TimeProvider() |
Initializes the TimeProvider. |
Properties
LocalTimeZone |
Gets a TimeZoneInfo object that represents the local time zone according to this TimeProvider's notion of time. |
System |
Gets a TimeProvider that provides a clock based on UtcNow, a time zone based on Local, a high-performance time stamp based on Stopwatch, and a timer based on Timer. |
TimestampFrequency |
Gets the frequency of GetTimestamp() of high-frequency value per second. |
Methods
CreateTimer(TimerCallback, Object, TimeSpan, TimeSpan) |
Creates a new ITimer instance, using TimeSpan values to measure time intervals. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetElapsedTime(Int64) |
Gets the elapsed time since the |
GetElapsedTime(Int64, Int64) |
Gets the elapsed time between two timestamps retrieved using GetTimestamp(). |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetLocalNow() |
Gets a DateTimeOffset value that is set to the current date and time according to this TimeProvider's notion of time based on GetUtcNow(), with the offset set to the LocalTimeZone's offset from Coordinated Universal Time (UTC). |
GetTimestamp() |
Gets the current high-frequency value designed to measure small time intervals with high accuracy in the timer mechanism. |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
GetUtcNow() |
Gets a DateTimeOffset value whose date and time are set to the current Coordinated Universal Time (UTC) date and time and whose offset is Zero, all according to this TimeProvider's notion of time. |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |
Extension Methods
CreateCancellationTokenSource(TimeProvider, TimeSpan) |
Initializes a new instance of the CancellationTokenSource class that will be canceled after the specified TimeSpan. |
Delay(TimeProvider, TimeSpan, CancellationToken) |
Creates a task that completes after a specified time interval. |