Grain.RegisterTimer 方法

定义

注意

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

注册计时器以向此粒度发送定期回调。

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

参数

asyncCallbackcallback
Func<Object,Task>

计时器计时周期时要调用的回调函数。

state
Object

调用 callback时将作为参数传递的状态对象。

dueTime
TimeSpan

第一个计时器时钟周期的到期时间。

period
TimeSpan

后续计时器计时周期的时间段。

返回

此计时器的句柄。

属性

注解

此计时器不会阻止当前粒度被停用。 如果停用粒度,则会丢弃计时器。

在解析从回调返回的任务之前,不会计划下一个计时器时钟周期。 也就是说,计时器回调永远不会交错轮次。

通过在从此调用返回的计时器句柄上调用 Dispose 方法,随时可以停止计时器。

将记录由回调返回或出错的任务引发的任何异常,但不会阻止下一个计时器计时周期排队。

适用于

另请参阅