Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

PeriodicTimer Class

Definition

Namespace:
System.Threading
Assembly:
System.Runtime.dll
Source:
PeriodicTimer.cs
Source:
PeriodicTimer.cs
Source:
PeriodicTimer.cs
Source:
PeriodicTimer.cs
Source:
PeriodicTimer.cs

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 a periodic timer that enables waiting asynchronously for timer ticks.

public ref class PeriodicTimer sealed : IDisposable
public sealed class PeriodicTimer : IDisposable
type PeriodicTimer = class
 interface IDisposable
Public NotInheritable Class PeriodicTimer
Implements IDisposable
Inheritance
PeriodicTimer
Implements

Remarks

This timer is intended to be used only by a single consumer at a time: only one call to WaitForNextTickAsync(CancellationToken) may be in flight at any given moment.

Dispose() may be used concurrently with an active WaitForNextTickAsync(CancellationToken) to interrupt it and cause it to return false.

Constructors

Name Description
PeriodicTimer(TimeSpan, TimeProvider)

Initializes the timer.

PeriodicTimer(TimeSpan)

Initializes the timer.

Properties

Name Description
Period

Gets or sets the period between ticks.

Methods

Name Description
Dispose()

Stops the timer and releases the associated managed resources.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize()

Ensures that resources are freed and other cleanup operations are performed when the garbage collector reclaims the PeriodicTimer object.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)
WaitForNextTickAsync(CancellationToken)

Waits for the next tick of the timer, or for the timer to be stopped.

Applies to


Feedback

Was this page helpful?