Edit

Share via


GrainBaseExtensions.RegisterGrainTimer Method

Definition

Overloads

RegisterGrainTimer(IGrainBase, Func<CancellationToken,Task>, GrainTimerCreationOptions)

Creates a grain timer.

RegisterGrainTimer(IGrainBase, Func<Task>, GrainTimerCreationOptions)
RegisterGrainTimer(IGrainBase, Func<CancellationToken,Task>, TimeSpan, TimeSpan)

Creates a grain timer.

RegisterGrainTimer(IGrainBase, Func<Task>, TimeSpan, TimeSpan)

Creates a grain timer.

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

Creates a grain timer.

RegisterGrainTimer<TState>(IGrainBase, Func<TState,Task>, TState, GrainTimerCreationOptions)
RegisterGrainTimer<TState>(IGrainBase, Func<TState,CancellationToken,Task>, TState, TimeSpan, TimeSpan)

Creates a grain timer.

RegisterGrainTimer<TState>(IGrainBase, Func<TState,Task>, TState, TimeSpan, TimeSpan)

Creates a grain timer.

RegisterGrainTimer(IGrainBase, Func<CancellationToken,Task>, GrainTimerCreationOptions)

Creates a grain timer.

public static Orleans.Runtime.IGrainTimer RegisterGrainTimer (this Orleans.IGrainBase grain, Func<System.Threading.CancellationToken,System.Threading.Tasks.Task> callback, Orleans.Runtime.GrainTimerCreationOptions options);
static member RegisterGrainTimer : Orleans.IGrainBase * Func<System.Threading.CancellationToken, System.Threading.Tasks.Task> * Orleans.Runtime.GrainTimerCreationOptions -> Orleans.Runtime.IGrainTimer
<Extension()>
Public Function RegisterGrainTimer (grain As IGrainBase, callback As Func(Of CancellationToken, Task), options As GrainTimerCreationOptions) As IGrainTimer

Parameters

grain
IGrainBase

The grain instance.

callback
Func<CancellationToken,Task>

The timer callback, which will be invoked whenever the timer becomes due.

options
GrainTimerCreationOptions

The options for creating the timer.

Returns

The IGrainTimer instance which represents the timer.

Remarks

Grain timers do not keep grains active by default. Setting KeepAlive to true causes each timer tick to extend the grain activation's lifetime. If the timer ticks are infrequent, the grain can still be deactivated due to idleness. When a grain is deactivated, all active timers are discarded.

Until the Task returned from the callback is resolved, the next timer tick will not be scheduled. That is to say, a timer callback will never be concurrently executed with itself. If Interleave is set to true, the timer callback will be allowed to interleave with with other grain method calls and other timers. If Interleave is set to false, the timer callback will respect the reentrancy setting of the grain, just like a typical grain method call.

The timer may be stopped at any time by calling the IGrainTimer's Dispose() method. Disposing a timer prevents any further timer ticks from being scheduled.

The timer due time and period can be updated by calling its Change(TimeSpan, TimeSpan) method. Each time the timer is updated, the next timer tick will be scheduled based on the updated due time. Subsequent ticks will be scheduled after the updated period elapses. Note that this behavior is the same as the Change(TimeSpan, TimeSpan) method.

Exceptions thrown from the callback will be logged, but will not prevent the next timer tick from being queued.

Applies to

RegisterGrainTimer(IGrainBase, Func<Task>, GrainTimerCreationOptions)

public static Orleans.Runtime.IGrainTimer RegisterGrainTimer (this Orleans.IGrainBase grain, Func<System.Threading.Tasks.Task> callback, Orleans.Runtime.GrainTimerCreationOptions options);
static member RegisterGrainTimer : Orleans.IGrainBase * Func<System.Threading.Tasks.Task> * Orleans.Runtime.GrainTimerCreationOptions -> Orleans.Runtime.IGrainTimer
<Extension()>
Public Function RegisterGrainTimer (grain As IGrainBase, callback As Func(Of Task), options As GrainTimerCreationOptions) As IGrainTimer

Parameters

grain
IGrainBase
callback
Func<Task>

Returns

Applies to

RegisterGrainTimer(IGrainBase, Func<CancellationToken,Task>, TimeSpan, TimeSpan)

Creates a grain timer.

public static Orleans.Runtime.IGrainTimer RegisterGrainTimer (this Orleans.IGrainBase grain, Func<System.Threading.CancellationToken,System.Threading.Tasks.Task> callback, TimeSpan dueTime, TimeSpan period);
static member RegisterGrainTimer : Orleans.IGrainBase * Func<System.Threading.CancellationToken, System.Threading.Tasks.Task> * TimeSpan * TimeSpan -> Orleans.Runtime.IGrainTimer
<Extension()>
Public Function RegisterGrainTimer (grain As IGrainBase, callback As Func(Of CancellationToken, Task), dueTime As TimeSpan, period As TimeSpan) As IGrainTimer

Parameters

grain
IGrainBase

The grain instance.

callback
Func<CancellationToken,Task>

The timer callback, which will be invoked whenever the timer becomes due.

dueTime
TimeSpan

A TimeSpan representing the amount of time to delay before invoking the callback method specified when the IGrainTimer was constructed. Specify InfiniteTimeSpan to prevent the timer from starting. Specify Zero to start the timer immediately.

period
TimeSpan

The time interval between invocations of the callback method specified when the IGrainTimer was constructed. Specify InfiniteTimeSpan to disable periodic signaling.

Returns

The IGrainTimer instance which represents the timer.

Applies to

RegisterGrainTimer(IGrainBase, Func<Task>, TimeSpan, TimeSpan)

Creates a grain timer.

public static Orleans.Runtime.IGrainTimer RegisterGrainTimer (this Orleans.IGrainBase grain, Func<System.Threading.Tasks.Task> callback, TimeSpan dueTime, TimeSpan period);
static member RegisterGrainTimer : Orleans.IGrainBase * Func<System.Threading.Tasks.Task> * TimeSpan * TimeSpan -> Orleans.Runtime.IGrainTimer
<Extension()>
Public Function RegisterGrainTimer (grain As IGrainBase, callback As Func(Of Task), dueTime As TimeSpan, period As TimeSpan) As IGrainTimer

Parameters

grain
IGrainBase

The grain instance.

callback
Func<Task>

The timer callback, which will be invoked whenever the timer becomes due.

dueTime
TimeSpan

A TimeSpan representing the amount of time to delay before invoking the callback method specified when the IGrainTimer was constructed. Specify InfiniteTimeSpan to prevent the timer from starting. Specify Zero to start the timer immediately.

period
TimeSpan

The time interval between invocations of the callback method specified when the IGrainTimer was constructed. Specify InfiniteTimeSpan to disable periodic signaling.

Returns

The IGrainTimer instance which represents the timer.

Remarks

Grain timers do not keep grains active by default. Setting KeepAlive to true causes each timer tick to extend the grain activation's lifetime. If the timer ticks are infrequent, the grain can still be deactivated due to idleness. When a grain is deactivated, all active timers are discarded.

Until the Task returned from the callback is resolved, the next timer tick will not be scheduled. That is to say, a timer callback will never be concurrently executed with itself. If Interleave is set to true, the timer callback will be allowed to interleave with with other grain method calls and other timers. If Interleave is set to false, the timer callback will respect the reentrancy setting of the grain, just like a typical grain method call.

The timer may be stopped at any time by calling the IGrainTimer's Dispose() method. Disposing a timer prevents any further timer ticks from being scheduled.

The timer due time and period can be updated by calling its Change(TimeSpan, TimeSpan) method. Each time the timer is updated, the next timer tick will be scheduled based on the updated due time. Subsequent ticks will be scheduled after the updated period elapses. Note that this behavior is the same as the Change(TimeSpan, TimeSpan) method.

Exceptions thrown from the callback will be logged, but will not prevent the next timer tick from being queued.

Applies to

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

Creates a grain timer.

public static Orleans.Runtime.IGrainTimer RegisterGrainTimer<TState> (this Orleans.IGrainBase grain, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.Task> callback, TState state, Orleans.Runtime.GrainTimerCreationOptions options);
static member RegisterGrainTimer : Orleans.IGrainBase * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task> * 'State * Orleans.Runtime.GrainTimerCreationOptions -> Orleans.Runtime.IGrainTimer
<Extension()>
Public Function RegisterGrainTimer(Of TState) (grain As IGrainBase, callback As Func(Of TState, CancellationToken, Task), state As TState, options As GrainTimerCreationOptions) As IGrainTimer

Type Parameters

TState

The type of the state parameter.

Parameters

grain
IGrainBase
callback
Func<TState,CancellationToken,Task>

The timer callback, which will be invoked whenever the timer becomes due.

state
TState

The state passed to the callback.

options
GrainTimerCreationOptions

The options for creating the timer.

Returns

The IGrainTimer instance which represents the timer.

Remarks

Grain timers do not keep grains active by default. Setting KeepAlive to true causes each timer tick to extend the grain activation's lifetime. If the timer ticks are infrequent, the grain can still be deactivated due to idleness. When a grain is deactivated, all active timers are discarded.

Until the Task returned from the callback is resolved, the next timer tick will not be scheduled. That is to say, a timer callback will never be concurrently executed with itself. If Interleave is set to true, the timer callback will be allowed to interleave with with other grain method calls and other timers. If Interleave is set to false, the timer callback will respect the reentrancy setting of the grain, just like a typical grain method call.

The timer may be stopped at any time by calling the IGrainTimer's Dispose() method. Disposing a timer prevents any further timer ticks from being scheduled.

The timer due time and period can be updated by calling its Change(TimeSpan, TimeSpan) method. Each time the timer is updated, the next timer tick will be scheduled based on the updated due time. Subsequent ticks will be scheduled after the updated period elapses. Note that this behavior is the same as the Change(TimeSpan, TimeSpan) method.

Exceptions thrown from the callback will be logged, but will not prevent the next timer tick from being queued.

Applies to

RegisterGrainTimer<TState>(IGrainBase, Func<TState,Task>, TState, GrainTimerCreationOptions)

public static Orleans.Runtime.IGrainTimer RegisterGrainTimer<TState> (this Orleans.IGrainBase grain, Func<TState,System.Threading.Tasks.Task> callback, TState state, Orleans.Runtime.GrainTimerCreationOptions options);
static member RegisterGrainTimer : Orleans.IGrainBase * Func<'State, System.Threading.Tasks.Task> * 'State * Orleans.Runtime.GrainTimerCreationOptions -> Orleans.Runtime.IGrainTimer
<Extension()>
Public Function RegisterGrainTimer(Of TState) (grain As IGrainBase, callback As Func(Of TState, Task), state As TState, options As GrainTimerCreationOptions) As IGrainTimer

Type Parameters

TState

The type of the state parameter.

Parameters

grain
IGrainBase
callback
Func<TState,Task>
state
TState

The state passed to the callback.

Returns

Applies to

RegisterGrainTimer<TState>(IGrainBase, Func<TState,CancellationToken,Task>, TState, TimeSpan, TimeSpan)

Creates a grain timer.

public static Orleans.Runtime.IGrainTimer RegisterGrainTimer<TState> (this Orleans.IGrainBase grain, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.Task> callback, TState state, TimeSpan dueTime, TimeSpan period);
static member RegisterGrainTimer : Orleans.IGrainBase * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task> * 'State * TimeSpan * TimeSpan -> Orleans.Runtime.IGrainTimer
<Extension()>
Public Function RegisterGrainTimer(Of TState) (grain As IGrainBase, callback As Func(Of TState, CancellationToken, Task), state As TState, dueTime As TimeSpan, period As TimeSpan) As IGrainTimer

Type Parameters

TState

The type of the state parameter.

Parameters

grain
IGrainBase

The grain instance.

callback
Func<TState,CancellationToken,Task>

The timer callback, which will be invoked whenever the timer becomes due.

state
TState

The state passed to the callback.

dueTime
TimeSpan

A TimeSpan representing the amount of time to delay before invoking the callback method specified when the IGrainTimer was constructed. Specify InfiniteTimeSpan to prevent the timer from starting. Specify Zero to start the timer immediately.

period
TimeSpan

The time interval between invocations of the callback method specified when the IGrainTimer was constructed. Specify InfiniteTimeSpan to disable periodic signaling.

Returns

The IGrainTimer instance which represents the timer.

Applies to

RegisterGrainTimer<TState>(IGrainBase, Func<TState,Task>, TState, TimeSpan, TimeSpan)

Creates a grain timer.

public static Orleans.Runtime.IGrainTimer RegisterGrainTimer<TState> (this Orleans.IGrainBase grain, Func<TState,System.Threading.Tasks.Task> callback, TState state, TimeSpan dueTime, TimeSpan period);
static member RegisterGrainTimer : Orleans.IGrainBase * Func<'State, System.Threading.Tasks.Task> * 'State * TimeSpan * TimeSpan -> Orleans.Runtime.IGrainTimer
<Extension()>
Public Function RegisterGrainTimer(Of TState) (grain As IGrainBase, callback As Func(Of TState, Task), state As TState, dueTime As TimeSpan, period As TimeSpan) As IGrainTimer

Type Parameters

TState

The type of the state parameter.

Parameters

grain
IGrainBase

The grain instance.

callback
Func<TState,Task>

The timer callback, which will be invoked whenever the timer becomes due.

state
TState

The state passed to the callback.

dueTime
TimeSpan

A TimeSpan representing the amount of time to delay before invoking the callback method specified when the IGrainTimer was constructed. Specify InfiniteTimeSpan to prevent the timer from starting. Specify Zero to start the timer immediately.

period
TimeSpan

The time interval between invocations of the callback method specified when the IGrainTimer was constructed. Specify InfiniteTimeSpan to disable periodic signaling.

Returns

The IGrainTimer instance which represents the timer.

Applies to