Method RegisterAsyncTimer
- Namespace
- KZDev.SystemClock.PrimeTime
- Assembly
- KZDev.SystemClock.PrimeTime.dll
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.
IClockIntervalTimer RegisterAsyncTimer(TimeSpan callbackTime, TimeSpan repeatInterval, Func<ClockTimerCallbackContext, CancellationToken, ValueTask> callback, CancellationToken cancellationToken, object? state = null, IntervalTimerOptions? timerOptions = null)
Parameters
callbackTimeTimeSpanTime until the first callback.
repeatIntervalTimeSpanInterval for subsequent callbacks; InfiniteTimeSpan for one-shot.
callbackFunc<ClockTimerCallbackContext, CancellationToken, ValueTask>The async callback; receives timer context and a cancellation token.
cancellationTokenCancellationTokenToken that participates in cancelling the timer registration and is passed to the callback; use None when no external cancellation is required.
stateobjectOptional state passed to the callback via ClockTimerCallbackContext.
timerOptionsIntervalTimerOptionsOptional timer options.
Returns
- IClockIntervalTimer
An IClockIntervalTimer to monitor or change the timer.