Grain.RegisterTimer Method

Definition

Caution

Use 'this.RegisterGrainTimer(callback, state, new() { DueTime = dueTime, Period = period, Interleave = true })' instead.

Registers a timer to send periodic callbacks to this grain.

protected virtual IDisposable RegisterTimer (Func<object,System.Threading.Tasks.Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period);
protected IDisposable RegisterTimer (Func<object,System.Threading.Tasks.Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period);
[System.Obsolete("Use 'this.RegisterGrainTimer(callback, state, new() { DueTime = dueTime, Period = period, Interleave = true })' instead.")]
protected IDisposable RegisterTimer (Func<object?,System.Threading.Tasks.Task> callback, object? state, TimeSpan dueTime, TimeSpan period);
abstract member RegisterTimer : Func<obj, System.Threading.Tasks.Task> * obj * TimeSpan * TimeSpan -> IDisposable
override this.RegisterTimer : Func<obj, System.Threading.Tasks.Task> * obj * TimeSpan * TimeSpan -> IDisposable
member this.RegisterTimer : Func<obj, System.Threading.Tasks.Task> * obj * TimeSpan * TimeSpan -> IDisposable
[<System.Obsolete("Use 'this.RegisterGrainTimer(callback, state, new() { DueTime = dueTime, Period = period, Interleave = true })' instead.")>]
member this.RegisterTimer : Func<obj, System.Threading.Tasks.Task> * obj * TimeSpan * TimeSpan -> IDisposable
Protected Overridable Function RegisterTimer (asyncCallback As Func(Of Object, Task), state As Object, dueTime As TimeSpan, period As TimeSpan) As IDisposable
Protected Function RegisterTimer (asyncCallback As Func(Of Object, Task), state As Object, dueTime As TimeSpan, period As TimeSpan) As IDisposable
Protected Function RegisterTimer (callback As Func(Of Object, Task), state As Object, dueTime As TimeSpan, period As TimeSpan) As IDisposable

Parameters

asyncCallbackcallback
Func<Object,Task>

Callback function to be invoked when timer ticks.

state
Object

State object that will be passed as argument when calling the callback.

dueTime
TimeSpan

Due time for first timer tick.

period
TimeSpan

Period of subsequent timer ticks.

Returns

Handle for this timer.

Attributes

Remarks

This timer will not prevent the current grain from being deactivated. If the grain is deactivated, then the timer will be discarded.

Until the Task returned from the callback is resolved, the next timer tick will not be scheduled. That is to say, timer callbacks never interleave their turns.

The timer may be stopped at any time by calling the Dispose method on the timer handle returned from this call.

Any exceptions thrown by or faulted Task's returned from the callback will be logged, but will not prevent the next timer tick from being queued.

Applies to

See also