DialogContext.EndDialogAsync(Object, CancellationToken) Method

Definition

Ends a dialog by popping it off the stack and returns an optional result to the dialog's parent. The parent dialog is the dialog the started the on being ended via a call to either BeginDialogAsync(String, Object, CancellationToken) or PromptAsync(String, PromptOptions, CancellationToken). The parent dialog will have its ResumeDialogAsync(DialogContext, DialogReason, Object, CancellationToken) method invoked with any returned result. If the parent dialog hasn't implemented a ResumeDialogAsync method, then it will be automatically ended as well and the result passed to its parent. If there are no more parent dialogs on the stack then processing of the turn will end.

public System.Threading.Tasks.Task<Microsoft.Bot.Builder.Dialogs.DialogTurnResult> EndDialogAsync (object result = default, System.Threading.CancellationToken cancellationToken = default);
member this.EndDialogAsync : obj * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Bot.Builder.Dialogs.DialogTurnResult>
Public Function EndDialogAsync (Optional result As Object = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of DialogTurnResult)

Parameters

result
Object

Optional, result to pass to the parent context.

cancellationToken
CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

A task that represents the work queued to execute.

Remarks

If the task is successful, the result indicates that the dialog ended after the turn was processed by the dialog.

In general, the parent context is the dialog or bot turn handler that started the dialog. If the parent is a dialog, the stack calls the parent's ResumeDialogAsync(DialogContext, DialogReason, Object, CancellationToken) method to return a result to the parent dialog. If the parent dialog does not implement `ResumeDialogAsync`, then the parent will end, too, and the result passed to the next parent context.

The returned DialogTurnResult contains the return value in its Result property.

Applies to

See also