Compartilhar via


TaskOrchestrationContext.WaitForExternalEvent Method

Definition

Overloads

WaitForExternalEvent<T>(String, CancellationToken)

Waits for an event to be raised with name eventName and returns the event data.

WaitForExternalEvent<T>(String, TimeSpan)

Waits for an event to be raised with name eventName and returns the event data.

WaitForExternalEvent<T>(String, CancellationToken)

Waits for an event to be raised with name eventName and returns the event data.

public abstract System.Threading.Tasks.Task<T> WaitForExternalEvent<T> (string eventName, System.Threading.CancellationToken cancellationToken = default);
abstract member WaitForExternalEvent : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>
Public MustOverride Function WaitForExternalEvent(Of T) (eventName As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of T)

Type Parameters

T

Any serializable type that represents the event payload.

Parameters

eventName
String

The name of the event to wait for. Event names are case-insensitive. External event names can be reused any number of times; they are not required to be unique.

cancellationToken
CancellationToken

A CancellationToken to use to abort waiting for the event.

Returns

Task<T>

A task that completes when the external event is received. The value of the task is the deserialized event payload.

Exceptions

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

Remarks

External clients can raise events to a waiting orchestration instance. Similarly, orchestrations can raise events to other orchestrations using the SendEvent(String, String, Object) method.

If the current orchestrator instance is not yet waiting for an event named eventName, then the event will be saved in the orchestration instance state and dispatched immediately when this method is called. This event saving occurs even if the current orchestrator cancels the wait operation before the event is received.

Orchestrators can wait for the same event name multiple times, so waiting for multiple events with the same name is allowed. Each external event received by an orchestrator will complete just one task returned by this method.

Applies to

WaitForExternalEvent<T>(String, TimeSpan)

Waits for an event to be raised with name eventName and returns the event data.

public System.Threading.Tasks.Task<T> WaitForExternalEvent<T> (string eventName, TimeSpan timeout);
member this.WaitForExternalEvent : string * TimeSpan -> System.Threading.Tasks.Task<'T>
Public Function WaitForExternalEvent(Of T) (eventName As String, timeout As TimeSpan) As Task(Of T)

Type Parameters

T

Any serializable type that represents the event payload.

Parameters

eventName
String

The name of the event to wait for. Event names are case-insensitive. External event names can be reused any number of times; they are not required to be unique.

timeout
TimeSpan

The amount of time to wait before cancelling the external event task.

Returns

Task<T>

A task that completes when the external event is received. The value of the task is the deserialized event payload.

Applies to