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 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)
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.
Returns The newly created <see cref="T:System.Threading.ITimer" /> instance.
Creates a new <see cref="T:System.Threading.ITimer" /> instance, using <see cref="T:System.TimeSpan" /> values to measure time intervals.
public TimeSpan
GetElapsedTime​(long startingTimestamp)
startingTimestamp The timestamp marking the beginning of the time period.
Returns A <see cref="T:System.TimeSpan" /> for the elapsed time between the starting timestamp and the time of this call.
Gets the elapsed time since the <paramref name="startingTimestamp" /> value retrieved using <see cref="M:System.TimeProvider.GetTimestamp" /> .
public TimeSpan
GetElapsedTime​(long startingTimestamp, long endingTimestamp)
startingTimestamp The timestamp marking the beginning of the time period.
endingTimestamp The timestamp marking the end of the time period.
Returns A <see cref="T:System.TimeSpan" /> for the elapsed time between the starting and ending timestamps.
Gets the elapsed time between two timestamps retrieved using <see cref="M:System.TimeProvider.GetTimestamp" /> .
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​()
Returns A long integer representing the high-frequency counter value of the underlying timer mechanism.
Gets the current high-frequency value designed to measure small time intervals with high accuracy in the 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
obj The object to compare with the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
Determines whether the specified object is equal to 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
Returns A hash code for the current object.
Serves as the default hash function.
public Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates 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.