Grain.RegisterTimer Method

Definition

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);
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
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

Parameters

asyncCallback
Func<Object,Task>

Callback function to be invoked when timer ticks.

state
Object

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

dueTime
TimeSpan

Due time for first timer tick.

period
TimeSpan

Period of subsequent timer ticks.

Returns

Handle for this Timer.

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 asyncCallback 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 asyncCallback will be logged, but will not prevent the next timer tick from being queued.

Applies to

See also