Skip to content

ITimerRegistry Methods

Functionality for managing grain timers.

RegisterGrainTimer(IGrainContext, Func<TState, CancellationToken, Task>, TState, GrainTimerCreationOptions)

abstract
public abstract IGrainTimer RegisterGrainTimer<TState>(IGrainContext grainContext, Func<TState, CancellationToken, Task> callback, TState state, GrainTimerCreationOptions options)
Creates a grain timer.

Parameters

grainContextIGrainContext
The grain which the timer is associated with.
callbackFunc<TState, CancellationToken, Task>
The timer callback, which will be invoked whenever the timer becomes due.
stateTState
The state passed to the callback.
optionsGrainTimerCreationOptions
The options for creating the timer.

Returns

The IGrainTimer instance which represents the timer.

RegisterTimer(IGrainContext, Func<object?, Task>, object?, TimeSpan, TimeSpan)

abstract
[System.Obsolete(Use 'RegisterGrainTimer(grainContext, callback, state, new() { DueTime = dueTime, Period = period, Interleave = true })' instead.)]
public abstract IDisposable RegisterTimer(IGrainContext grainContext, Func<object?, Task> callback, object? state, TimeSpan dueTime, TimeSpan period)
Creates a grain timer.

Parameters

grainContextIGrainContext
The grain which the timer is associated with.
callbackFunc<object?, Task>
The timer callback, which will fire whenever the timer becomes due.
stateobject?
The state object passed to the callback.
dueTimeTimeSpan
The amount of time to delay before the callback is invoked. Specify System.Threading.Timeout.InfiniteTimeSpan to prevent the timer from starting. Specify System.TimeSpan.Zero to invoke the callback promptly.
periodTimeSpan
The time interval between invocations of callback. Specify System.Threading.Timeout.InfiniteTimeSpan to disable periodic signaling.

Returns

An System.IDisposable instance which represents the timer.