Table of Contents

Method RegisterAsyncTimer

Namespace
KZDev.PrimeTime.Testing
Assembly
KZDev.PrimeTime.Testing.dll

RegisterAsyncTimer(Duration, Duration, Func<ClockTimerCallbackContext, CancellationToken, ValueTask>, CancellationToken, object?, IntervalTimerOptions?)

Registers an interval timer with an initial delay, a repeat interval, and an asynchronous callback that receives timer context and cancellation token. Other NodaTime.Duration-based RegisterAsyncTimer overloads are extension methods.

public IClockIntervalTimer RegisterAsyncTimer(Duration callbackTime, Duration repeatInterval, Func<ClockTimerCallbackContext, CancellationToken, ValueTask> callback, CancellationToken cancellationToken, object? state = null, IntervalTimerOptions? timerOptions = null)

Parameters

callbackTime Duration

Duration until the first callback.

repeatInterval Duration

Interval for subsequent callbacks; use a non-positive duration for one-shot.

callback Func<ClockTimerCallbackContext, CancellationToken, ValueTask>

The async callback; receives timer context and a cancellation token.

cancellationToken CancellationToken

Token that participates in cancelling the timer registration and is passed to the callback; use None when no external cancellation is required.

state object

Optional state passed to the callback via ClockTimerCallbackContext.

timerOptions IntervalTimerOptions

Optional timer options.

Returns

IClockIntervalTimer

An IClockIntervalTimer to monitor or change the timer.

RegisterAsyncTimer(TimeSpan, TimeSpan, Func<ClockTimerCallbackContext, CancellationToken, ValueTask>, CancellationToken, object?, IntervalTimerOptions?)

Registers an interval timer with an initial delay, a repeat interval, and an asynchronous callback that receives timer context and cancellation token. Other RegisterAsyncTimer overloads are provided as extension methods.

public IClockIntervalTimer RegisterAsyncTimer(TimeSpan callbackTime, TimeSpan repeatInterval, Func<ClockTimerCallbackContext, CancellationToken, ValueTask> callback, CancellationToken cancellationToken, object? state = null, IntervalTimerOptions? timerOptions = null)

Parameters

callbackTime TimeSpan

Time until the first callback.

repeatInterval TimeSpan

Interval for subsequent callbacks; InfiniteTimeSpan for one-shot.

callback Func<ClockTimerCallbackContext, CancellationToken, ValueTask>

The async callback; receives timer context and a cancellation token.

cancellationToken CancellationToken

Token that participates in cancelling the timer registration and is passed to the callback; use None when no external cancellation is required.

state object

Optional state passed to the callback via ClockTimerCallbackContext.

timerOptions IntervalTimerOptions

Optional timer options.

Returns

IClockIntervalTimer

An IClockIntervalTimer to monitor or change the timer.