Method RegisterTimer
RegisterTimer(IPrimeClock, Duration, Action, CancellationToken, bool, IntervalTimerOptions?)
Registers a one-shot or repeating interval timer with a synchronous callback.
public static IClockIntervalTimer RegisterTimer(this IPrimeClock clock, Duration callbackTime, Action callback, CancellationToken cancellationToken, bool repeat = false, IntervalTimerOptions? timerOptions = null)
Parameters
clockIPrimeClockThe clock on which to register the timer.
callbackTimeDurationDuration until the first callback.
callbackActionThe callback to run when the timer fires.
cancellationTokenCancellationTokenToken that participates in cancelling the timer registration; pass None when no external cancellation is required.
repeatboolIf
true, repeat usingcallbackTimeas the interval.timerOptionsIntervalTimerOptionsOptional timer options (e.g. reset-before-callback, execution context).
Returns
- IClockIntervalTimer
An IClockIntervalTimer to monitor or change the timer.
RegisterTimer(IPrimeClock, Duration, Action<ClockTimerCallbackContext>, CancellationToken, object?, bool, IntervalTimerOptions?)
Registers a one-shot or repeating interval timer with a synchronous callback that receives context and state.
public static IClockIntervalTimer RegisterTimer(this IPrimeClock clock, Duration callbackTime, Action<ClockTimerCallbackContext> callback, CancellationToken cancellationToken, object? state = null, bool repeat = false, IntervalTimerOptions? timerOptions = null)
Parameters
clockIPrimeClockThe clock on which to register the timer.
callbackTimeDurationDuration until the first callback.
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.
repeatboolIf
true, repeat usingcallbackTimeas the interval.timerOptionsIntervalTimerOptionsOptional timer options (e.g. reset-before-callback, execution context).
Returns
- IClockIntervalTimer
An IClockIntervalTimer to monitor or change the timer.
RegisterTimer(IPrimeClock, Duration, Action<ClockTimerCallbackContext, CancellationToken>, CancellationToken, object?, bool, IntervalTimerOptions?)
Registers a one-shot or repeating interval timer with a synchronous callback that receives context and cancellation token.
public static IClockIntervalTimer RegisterTimer(this IPrimeClock clock, Duration callbackTime, Action<ClockTimerCallbackContext, CancellationToken> callback, CancellationToken cancellationToken, object? state = null, bool repeat = false, IntervalTimerOptions? timerOptions = null)
Parameters
clockIPrimeClockThe clock on which to register the timer.
callbackTimeDurationDuration until the first callback.
callbackAction<ClockTimerCallbackContext, CancellationToken>The callback invoked when the timer fires; receives timer context and a cancellation token.
cancellationTokenCancellationTokenToken that participates in cancelling the timer registration; pass None when no external cancellation is required.
stateobjectOptional state passed to the callback via ClockTimerCallbackContext.
repeatboolIf
true, repeat usingcallbackTimeas the interval.timerOptionsIntervalTimerOptionsOptional timer options (e.g. reset-before-callback, execution context).
Returns
- IClockIntervalTimer
An IClockIntervalTimer to monitor or change the timer.
RegisterTimer(IPrimeClock, Duration, Duration, Action, CancellationToken, IntervalTimerOptions?)
Registers an interval timer with an initial delay and a separate repeat interval (sync callback).
public static IClockIntervalTimer RegisterTimer(this IPrimeClock clock, Duration callbackTime, Duration repeatInterval, Action callback, CancellationToken cancellationToken, IntervalTimerOptions? timerOptions = null)
Parameters
clockIPrimeClockThe clock on which to register the timer.
callbackTimeDurationDuration until the first callback.
repeatIntervalDurationInterval for subsequent callbacks; use a non-positive duration for one-shot.
callbackActionThe callback to run when the timer fires.
cancellationTokenCancellationTokenToken that participates in cancelling the timer registration; pass None when no external cancellation is required.
timerOptionsIntervalTimerOptionsOptional timer options.
Returns
- IClockIntervalTimer
An IClockIntervalTimer to monitor or change the timer.
RegisterTimer(IPrimeClock, Duration, Duration, Action<ClockTimerCallbackContext, CancellationToken>, CancellationToken, object?, IntervalTimerOptions?)
Registers an interval timer with an initial delay and a separate repeat interval (sync callback with context and token).
public static IClockIntervalTimer RegisterTimer(this IPrimeClock clock, Duration callbackTime, Duration repeatInterval, Action<ClockTimerCallbackContext, CancellationToken> callback, CancellationToken cancellationToken, object? state = null, IntervalTimerOptions? timerOptions = null)
Parameters
clockIPrimeClockThe clock on which to register the timer.
callbackTimeDurationDuration until the first callback.
repeatIntervalDurationInterval for subsequent callbacks; use a non-positive duration for one-shot.
callbackAction<ClockTimerCallbackContext, CancellationToken>The callback invoked when the timer fires; receives timer context and a cancellation token.
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.