Share via


BotAdapter.RunPipelineAsync Method

Definition

Starts activity processing for the current bot turn.

protected System.Threading.Tasks.Task RunPipelineAsync (Microsoft.Bot.Builder.ITurnContext turnContext, Microsoft.Bot.Builder.BotCallbackHandler callback, System.Threading.CancellationToken cancellationToken);
member this.RunPipelineAsync : Microsoft.Bot.Builder.ITurnContext * Microsoft.Bot.Builder.BotCallbackHandler * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Protected Function RunPipelineAsync (turnContext As ITurnContext, callback As BotCallbackHandler, cancellationToken As CancellationToken) As Task

Parameters

turnContext
ITurnContext

The turn's context object.

callback
BotCallbackHandler

A callback method to run at the end of the pipeline.

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.

Exceptions

turnContext is null.

Remarks

The adapter calls middleware in the order in which you added it. The adapter passes in the context object for the turn and a next delegate, and the middleware calls the delegate to pass control to the next middleware in the pipeline. Once control reaches the end of the pipeline, the adapter calls the callback method. If a middleware component doesn’t call the next delegate, the adapter does not call any of the subsequent middleware’s OnTurnAsync(ITurnContext, NextDelegate, CancellationToken) methods or the callback method, and the pipeline short circuits.

When the turn is initiated by a user activity (reactive messaging), the callback method will be a reference to the bot's OnTurnAsync(ITurnContext, CancellationToken) method. When the turn is initiated by a call to ContinueConversationAsync(String, ConversationReference, BotCallbackHandler, CancellationToken) (proactive messaging), the callback method is the callback method that was provided in the call.

Applies to