共用方式為


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 方法,隨時可以停止定時器。

或從回呼傳回之工作傳回的任何例外狀況都會記錄,但不會防止下一個定時器刻度排入佇列。

適用於

另請參閱