Table of Contents

Method RegisterTimer

Namespace
KZDev.PrimeTime
Assembly
KZDev.PrimeTime.dll

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

clock IPrimeClock

The clock on which to register the timer.

callbackTime Duration

Duration until the first callback.

callback Action

The callback to run when the timer fires.

cancellationToken CancellationToken

Token that participates in cancelling the timer registration; pass None when no external cancellation is required.

repeat bool

If true, repeat using callbackTime as the interval.

timerOptions IntervalTimerOptions

Optional 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

clock IPrimeClock

The clock on which to register the timer.

callbackTime Duration

Duration until the first callback.

callback Action<ClockTimerCallbackContext>

The callback invoked when the timer fires; receives timer context.

cancellationToken CancellationToken

Token that participates in cancelling the timer registration; pass None when no external cancellation is required.

state object

Optional state passed to the callback via ClockTimerCallbackContext.

repeat bool

If true, repeat using callbackTime as the interval.

timerOptions IntervalTimerOptions

Optional 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

clock IPrimeClock

The clock on which to register the timer.

callbackTime Duration

Duration until the first callback.

callback Action<ClockTimerCallbackContext, CancellationToken>

The callback invoked when the timer fires; receives timer context and a cancellation token.

cancellationToken CancellationToken

Token that participates in cancelling the timer registration; pass None when no external cancellation is required.

state object

Optional state passed to the callback via ClockTimerCallbackContext.

repeat bool

If true, repeat using callbackTime as the interval.

timerOptions IntervalTimerOptions

Optional 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

clock IPrimeClock

The clock on which to register the timer.

callbackTime Duration

Duration until the first callback.

repeatInterval Duration

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

callback Action

The callback to run when the timer fires.

cancellationToken CancellationToken

Token that participates in cancelling the timer registration; pass None when no external cancellation is required.

timerOptions IntervalTimerOptions

Optional 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

clock IPrimeClock

The clock on which to register the timer.

callbackTime Duration

Duration until the first callback.

repeatInterval Duration

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

callback Action<ClockTimerCallbackContext, CancellationToken>

The callback invoked when the timer fires; receives timer context and a cancellation token.

cancellationToken CancellationToken

Token that participates in cancelling the timer registration; pass 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.