Method RegisterTimer
RegisterTimer(Duration, Duration, Action<ClockTimerCallbackContext>, CancellationToken, object?, IntervalTimerOptions?)
Registers an interval timer with an initial delay, a repeat interval, and a synchronous callback that receives
timer context. Other NodaTime.Duration-based RegisterTimer overloads are extension methods.
public IClockIntervalTimer RegisterTimer(Duration callbackTime, Duration repeatInterval, Action<ClockTimerCallbackContext> callback, CancellationToken cancellationToken, object? state = null, IntervalTimerOptions? timerOptions = null)
Parameters
callbackTimeDurationDuration until the first callback.
repeatIntervalDurationInterval for subsequent callbacks; use a non-positive duration for one-shot.
callbackAction<ClockTimerCallbackContext>The callback invoked when the timer fires; receives timer context.
cancellationTokenCancellationTokenToken that participates in cancelling the timer registration; pass 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.
RegisterTimer(TimeSpan, TimeSpan, Action<ClockTimerCallbackContext>, CancellationToken, object?, IntervalTimerOptions?)
Registers an interval timer with an initial delay, a repeat interval, and a synchronous callback that receives
timer context. Other RegisterTimer overloads are provided as extension methods.
public IClockIntervalTimer RegisterTimer(TimeSpan callbackTime, TimeSpan repeatInterval, Action<ClockTimerCallbackContext> callback, CancellationToken cancellationToken, object? state = null, IntervalTimerOptions? timerOptions = null)
Parameters
callbackTimeTimeSpanTime until the first callback.
repeatIntervalTimeSpanInterval for subsequent callbacks; InfiniteTimeSpan for one-shot.
callbackAction<ClockTimerCallbackContext>The callback invoked when the timer fires; receives timer context.
cancellationTokenCancellationTokenToken that participates in cancelling the timer registration; pass 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.