Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​TimeProvider

Assembly: System.Runtime

Inheritance: object → TimeProvider

Provides an abstraction for time.

Properties

public TimeZoneInfo
LocalTimeZone
Gets a <see cref="T:System.TimeZoneInfo" /> object that represents the local time zone according to this <see cref="T:System.TimeProvider" /> 's notion of time.
public static TimeProvider
System
Gets a <see cref="T:System.TimeProvider" /> that provides a clock based on <see cref="P:System.DateTimeOffset.UtcNow" /> , a time zone based on <see cref="P:System.TimeZoneInfo.Local" /> , a high-performance time stamp based on <see cref="T:System.Diagnostics.Stopwatch" /> , and a timer based on <see cref="T:System.Threading.Timer" /> .
public long
TimestampFrequency
Gets the frequency of <see cref="M:System.TimeProvider.GetTimestamp" /> of high-frequency value per second.

Methods

public ITimer
CreateTimer​(TimerCallback callback, object state, TimeSpan dueTime, TimeSpan period)
Creates a new <see cref="T:System.Threading.ITimer" /> instance, using <see cref="T:System.TimeSpan" /> values to measure time intervals.
Returns The newly created <see cref="T:System.Threading.ITimer" /> instance.
callback A delegate representing a method to be executed when the timer fires. The method specified for callback should be reentrant, as it may be invoked simultaneously on two threads if the timer fires again before or while a previous callback is still being handled.
state An object to be passed to the <paramref name="callback" /> . This may be null.
dueTime The amount of time to delay before <paramref name="callback" /> is invoked. Specify <see cref="F:System.Threading.Timeout.InfiniteTimeSpan" /> to prevent the timer from starting. Specify <see cref="F:System.TimeSpan.Zero" /> to start the timer immediately.
period The time interval between invocations of <paramref name="callback" /> . Specify <see cref="F:System.Threading.Timeout.InfiniteTimeSpan" /> to disable periodic signaling.
public TimeSpan
GetElapsedTime​(long startingTimestamp)
Gets the elapsed time since the <paramref name="startingTimestamp" /> value retrieved using <see cref="M:System.TimeProvider.GetTimestamp" /> .
Returns A <see cref="T:System.TimeSpan" /> for the elapsed time between the starting timestamp and the time of this call.
startingTimestamp The timestamp marking the beginning of the time period.
public TimeSpan
GetElapsedTime​(long startingTimestamp, long endingTimestamp)
Gets the elapsed time between two timestamps retrieved using <see cref="M:System.TimeProvider.GetTimestamp" /> .
Returns A <see cref="T:System.TimeSpan" /> for the elapsed time between the starting and ending timestamps.
startingTimestamp The timestamp marking the beginning of the time period.
endingTimestamp The timestamp marking the end of the time period.
GetLocalNow​()
Gets a <see cref="T:System.DateTimeOffset" /> value that is set to the current date and time according to this <see cref="T:System.TimeProvider" /> 's notion of time based on <see cref="M:System.TimeProvider.GetUtcNow" /> , with the offset set to the <see cref="P:System.TimeProvider.LocalTimeZone" /> 's offset from Coordinated Universal Time (UTC).
public long
GetTimestamp​()
Gets the current high-frequency value designed to measure small time intervals with high accuracy in the timer mechanism.
Returns A long integer representing the high-frequency counter value of the underlying timer mechanism.
GetUtcNow​()
Gets a <see cref="T:System.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 <see cref="T:System.TimeProvider" /> 's notion of time.
public bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj The object to compare with the current object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
public Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .
public string
ToString​()
Inherited from object
Returns a string that represents the current object.
Returns A string that represents the current object.