Skip to content

Latest commit

 

History

History
94 lines (61 loc) · 5.73 KB

TimeProviderExtensions.AutoAdvanceBehavior.md

File metadata and controls

94 lines (61 loc) · 5.73 KB

AutoAdvanceBehavior Class

The AutoAdvanceBehavior type provides a way to enable and customize the automatic advance of time.

public sealed class AutoAdvanceBehavior :
System.IEquatable<TimeProviderExtensions.AutoAdvanceBehavior>

Inheritance System.Object 🡒 AutoAdvanceBehavior

Implements System.IEquatable<AutoAdvanceBehavior>

Properties

AutoAdvanceBehavior.TimerAutoTriggerCount Property

Gets or sets the amount of times timer callbacks will automatically be triggered.

Setting this to a number greater than 0 causes any active timers to have their callback invoked until they have been invoked the number of times specified by TimerAutoTriggerCount. Before timer callbacks are invoked, time is advanced to match the time the callback was scheduled to be invoked, just as it is if Advance(TimeSpan) or SetUtcNow(DateTimeOffset) was manually called.

Setting this to 1 can be used to ensure all timers, e.g. those used by Task.Delay(TimeSpan, TimeProvider), Task.WaitAsync(TimeSpan, TimeProvider), CancellationTokenSource.CancelAfter(TimeSpan) and others are completed immediately.

Setting this to a number larger than 1, e.g. 10, can be used to automatically cause a PeriodicTimer(TimeSpan, TimeProvider) to automatically have its PeriodicTimer.WaitForNextTickAsync(CancellationToken) async enumerable return 10 times.

public int TimerAutoTriggerCount { get; set; }

Property Value

System.Int32

Exceptions

System.ArgumentOutOfRangeException
Thrown when set to a value less than zero 0.

Remarks

Set to 0 to disable auto timer callback invocation. The default value is zero 0.

AutoAdvanceBehavior.TimestampAdvanceAmount Property

Gets or sets the amount of time by which time advances whenever the a timestamp is read via System.TimeProvider.GetTimestamp or an elapsed time is calculated with System.TimeProvider.GetElapsedTime(System.Int64).

public System.TimeSpan TimestampAdvanceAmount { get; set; }

Property Value

System.TimeSpan

Exceptions

System.ArgumentOutOfRangeException
Thrown when set to a value less than System.TimeSpan.Zero.

Remarks

Set to System.TimeSpan.Zero to disable auto advance. The default value is System.TimeSpan.Zero.

AutoAdvanceBehavior.UtcNowAdvanceAmount Property

Gets or sets the amount of time by which time advances whenever the clock is read via System.TimeProvider.GetUtcNow or System.TimeProvider.GetLocalNow.

public System.TimeSpan UtcNowAdvanceAmount { get; set; }

Property Value

System.TimeSpan

Exceptions

System.ArgumentOutOfRangeException
Thrown when set to a value less than System.TimeSpan.Zero.

Remarks

Set to System.TimeSpan.Zero to disable auto advance. The default value is System.TimeSpan.Zero.