Compartilhar via


TaskOrchestrationContext.CreateTimer Method

Definition

Overloads

CreateTimer(TimeSpan, CancellationToken)

Creates a durable timer that expires after the specified delay.

CreateTimer(DateTime, CancellationToken)

Creates a durable timer that expires at a set date and time.

CreateTimer(TimeSpan, CancellationToken)

Creates a durable timer that expires after the specified delay.

public virtual System.Threading.Tasks.Task CreateTimer (TimeSpan delay, System.Threading.CancellationToken cancellationToken);
abstract member CreateTimer : TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.CreateTimer : TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function CreateTimer (delay As TimeSpan, cancellationToken As CancellationToken) As Task

Parameters

delay
TimeSpan

The amount of time before the timer should expire.

cancellationToken
CancellationToken

Used to cancel the durable timer.

Returns

A task that completes when the durable timer expires.

Exceptions

Thrown if the calling thread is anything other than the main orchestrator thread.

Remarks

All durable timers created using this method must either expire or be cancelled using the cancellationToken before the orchestrator can complete. If unexpired timers exist when the orchestration completes, it will remain in the "Running" state until the scheduled expiration time.

Specifying a long delay (for example, a delay of a few days or more) may result in the creation of multiple, internally-managed durable timers. The orchestration code doesn't need to be aware of this behavior. However, it may be visible in framework logs and the stored history state.

Applies to

CreateTimer(DateTime, CancellationToken)

Creates a durable timer that expires at a set date and time.

public abstract System.Threading.Tasks.Task CreateTimer (DateTime fireAt, System.Threading.CancellationToken cancellationToken);
abstract member CreateTimer : DateTime * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public MustOverride Function CreateTimer (fireAt As DateTime, cancellationToken As CancellationToken) As Task

Parameters

fireAt
DateTime

The time at which the timer should expire.

cancellationToken
CancellationToken

Used to cancel the durable timer.

Returns

A task that completes when the durable timer expires.

Applies to