IMiddleware.OnTurnAsync(ITurnContext, NextDelegate, CancellationToken) Method

Definition

When implemented in middleware, processes an incoming activity.

C#
public System.Threading.Tasks.Task OnTurnAsync(Microsoft.Agents.Protocols.Primitives.ITurnContext turnContext, Microsoft.Agents.Protocols.Primitives.NextDelegate next, System.Threading.CancellationToken cancellationToken = default);

Parameters

turnContext
ITurnContext

The context object for this turn.

next
NextDelegate

The delegate to call to continue the bot middleware 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.

Remarks

Middleware calls the next delegate to pass control to the next middleware in the pipeline. If middleware doesn’t call the next delegate, the adapter does not call any of the subsequent middleware’s request handlers or the bot’s receive handler, and the pipeline short circuits.

The turnContext provides information about the incoming activity, and other data needed to process the activity.

Applies to

Producto Versiones
Microsoft 365 Agents SDK .NET 1

See also