DialogContext.EndDialogAsync(Object, CancellationToken) Method


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)



Optional, result to pass to the parent context.


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



A task that represents the work queued to execute.


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
         <xref data-throw-if-not-resolved="true" uid="Microsoft.Bot.Builder.Dialogs.Dialog.ResumeDialogAsync(Microsoft.Bot.Builder.Dialogs.DialogContext,Microsoft.Bot.Builder.Dialogs.DialogReason,System.Object,System.Threading.CancellationToken)"></xref> 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 <xref data-throw-if-not-resolved="true" uid="Microsoft.Bot.Builder.Dialogs.DialogTurnResult"></xref> contains the return value in its
         <xref data-throw-if-not-resolved="true" uid="Microsoft.Bot.Builder.Dialogs.DialogTurnResult.Result"></xref> property.

Applies to

See also