Method RegisterTimer
- Namespace
- KZDev.SystemClock.PrimeTime
- Assembly
- KZDev.SystemClock.PrimeTime.dll
RegisterTimer(IPrimeClock, TimeSpan, 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, TimeSpan callbackTime, Action<ClockTimerCallbackContext> callback, CancellationToken cancellationToken, object? state = null, bool repeat = false, IntervalTimerOptions? timerOptions = null)
Parameters
clockIPrimeClockcallbackTimeTimeSpanTime 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, TimeSpan, 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, TimeSpan callbackTime, Action<ClockTimerCallbackContext, CancellationToken> callback, CancellationToken cancellationToken, object? state = null, bool repeat = false, IntervalTimerOptions? timerOptions = null)
Parameters
clockIPrimeClockcallbackTimeTimeSpanTime 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, TimeSpan, Action, CancellationToken, bool, IntervalTimerOptions?)
Registers a one-shot or repeating interval timer with a synchronous callback.
public static IClockIntervalTimer RegisterTimer(this IPrimeClock clock, TimeSpan callbackTime, Action callback, CancellationToken cancellationToken, bool repeat = false, IntervalTimerOptions? timerOptions = null)
Parameters
clockIPrimeClockcallbackTimeTimeSpanTime 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, TimeSpan, TimeSpan, 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, TimeSpan callbackTime, TimeSpan repeatInterval, Action<ClockTimerCallbackContext, CancellationToken> callback, CancellationToken cancellationToken, object? state = null, IntervalTimerOptions? timerOptions = null)
Parameters
clockIPrimeClockcallbackTimeTimeSpanTime until the first callback.
repeatIntervalTimeSpanInterval for subsequent callbacks; InfiniteTimeSpan 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.
RegisterTimer(IPrimeClock, TimeSpan, TimeSpan, 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, TimeSpan callbackTime, TimeSpan repeatInterval, Action callback, CancellationToken cancellationToken, IntervalTimerOptions? timerOptions = null)
Parameters
clockIPrimeClockcallbackTimeTimeSpanTime until the first callback.
repeatIntervalTimeSpanInterval for subsequent callbacks; InfiniteTimeSpan 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.