Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 3.22 KB

System.Threading.TimeProviderPeriodicTimerExtensions.md

File metadata and controls

44 lines (30 loc) · 3.22 KB

TimeProviderPeriodicTimerExtensions Class

PeriodicTimer extensions for System.TimeProvider.

public static class TimeProviderPeriodicTimerExtensions

Inheritance System.Object 🡒 TimeProviderPeriodicTimerExtensions

Methods

TimeProviderPeriodicTimerExtensions.CreatePeriodicTimer(this TimeProvider, TimeSpan) Method

Factory method that creates a periodic timer that enables waiting asynchronously for timer ticks. Use this factory method as a replacement for instantiating a System.Threading.PeriodicTimer.

public static System.Threading.PeriodicTimerWrapper CreatePeriodicTimer(this TimeProvider timeProvider, System.TimeSpan period);

Parameters

timeProvider System.TimeProvider

period System.TimeSpan

Returns

PeriodicTimerWrapper
A new PeriodicTimerWrapper. Note, this is a wrapper around a System.Threading.PeriodicTimer, and will behave exactly the same as the original.

Remarks

This timer is intended to be used only by a single consumer at a time: only one call to System.Threading.PeriodicTimer.WaitForNextTickAsync(System.Threading.CancellationToken) may be in flight at any given moment. System.Threading.PeriodicTimer.Dispose may be used concurrently with an active System.Threading.PeriodicTimer.WaitForNextTickAsync(System.Threading.CancellationToken) to interrupt it and cause it to return false.