RouteBuilder.AddHandler Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| AddHandler<TInput,TResult>(Func<TInput,IWorkflowContext,CancellationToken,ValueTask<TResult>>, Boolean) |
Registers a handler function for messages of the specified input type in the workflow route. |
| AddHandler<TInput,TResult>(Func<TInput,IWorkflowContext,CancellationToken,TResult>, Boolean) |
Registers a handler function for messages of the specified input type in the workflow route. |
| AddHandler<TInput,TResult>(Func<TInput,IWorkflowContext,ValueTask<TResult>>, Boolean) |
Registers a handler function for messages of the specified input type in the workflow route. |
| AddHandler<TInput,TResult>(Func<TInput,IWorkflowContext,TResult>, Boolean) |
Registers a handler function for messages of the specified input type in the workflow route. |
| AddHandler<TInput>(Action<TInput,IWorkflowContext,CancellationToken>, Boolean) |
Registers a handler for messages of the specified input type in the workflow route. |
| AddHandler<TInput>(Action<TInput,IWorkflowContext>, Boolean) |
Registers a handler for messages of the specified input type in the workflow route. |
| AddHandler<TInput>(Func<TInput,IWorkflowContext,CancellationToken,ValueTask>, Boolean) |
Registers a handler for messages of the specified input type in the workflow route. |
| AddHandler<TInput>(Func<TInput,IWorkflowContext,ValueTask>, Boolean) |
Registers a handler for messages of the specified input type in the workflow route. |
AddHandler<TInput,TResult>(Func<TInput,IWorkflowContext,CancellationToken,ValueTask<TResult>>, Boolean)
Registers a handler function for messages of the specified input type in the workflow route.
public Microsoft.Agents.AI.Workflows.RouteBuilder AddHandler<TInput,TResult>(Func<TInput,Microsoft.Agents.AI.Workflows.IWorkflowContext,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TResult>> handler, bool overwrite = false);
member this.AddHandler : Func<'Input, Microsoft.Agents.AI.Workflows.IWorkflowContext, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Result>> * bool -> Microsoft.Agents.AI.Workflows.RouteBuilder
Public Function AddHandler(Of TInput, TResult) (handler As Func(Of TInput, IWorkflowContext, CancellationToken, ValueTask(Of TResult)), Optional overwrite As Boolean = false) As RouteBuilder
Type Parameters
- TInput
The type of input message the handler will process.
- TResult
The type of result produced by the handler.
Parameters
- handler
- Func<TInput,IWorkflowContext,CancellationToken,ValueTask<TResult>>
A function that processes messages of type TInput within the workflow context and returns
a ValueTask<TResult> representing the asynchronous result.
- overwrite
- Boolean
Set true to replace an existing handler for the specified input type; if no
handler is registered will throw. If set to false and a handler is registered, this will throw.
Returns
The current RouteBuilder instance, enabling fluent configuration of workflow routes.
Exceptions
If a handler is already registered for the specified type, and overwrite is set
to false, or if a handler is not already registered, but overwrite is set to true.
Remarks
If a handler for the given input type already exists, setting overwrite to true will replace the existing handler; otherwise, an exception may be thrown. The handler receives the input message and workflow context, and returns a result asynchronously.
Applies to
AddHandler<TInput,TResult>(Func<TInput,IWorkflowContext,CancellationToken,TResult>, Boolean)
Registers a handler function for messages of the specified input type in the workflow route.
public Microsoft.Agents.AI.Workflows.RouteBuilder AddHandler<TInput,TResult>(Func<TInput,Microsoft.Agents.AI.Workflows.IWorkflowContext,System.Threading.CancellationToken,TResult> handler, bool overwrite = false);
member this.AddHandler : Func<'Input, Microsoft.Agents.AI.Workflows.IWorkflowContext, System.Threading.CancellationToken, 'Result> * bool -> Microsoft.Agents.AI.Workflows.RouteBuilder
Public Function AddHandler(Of TInput, TResult) (handler As Func(Of TInput, IWorkflowContext, CancellationToken, TResult), Optional overwrite As Boolean = false) As RouteBuilder
Type Parameters
- TInput
The type of input message the handler will process.
- TResult
The type of result produced by the handler.
Parameters
- handler
- Func<TInput,IWorkflowContext,CancellationToken,TResult>
A function that processes messages of type TInput within the workflow context and returns
a ValueTask<TResult> representing the asynchronous result.
- overwrite
- Boolean
Set true to replace an existing handler for the specified input type; if no
handler is registered will throw. If set to false and a handler is registered, this will throw.
Returns
The current RouteBuilder instance, enabling fluent configuration of workflow routes.
Exceptions
If a handler is already registered for the specified type, and overwrite is set
to false, or if a handler is not already registered, but overwrite is set to true.
Remarks
If a handler for the given input type already exists, setting overwrite to true will replace the existing handler; otherwise, an exception may be thrown. The handler receives the input message and workflow context, and returns a result asynchronously.
Applies to
AddHandler<TInput,TResult>(Func<TInput,IWorkflowContext,ValueTask<TResult>>, Boolean)
Registers a handler function for messages of the specified input type in the workflow route.
public Microsoft.Agents.AI.Workflows.RouteBuilder AddHandler<TInput,TResult>(Func<TInput,Microsoft.Agents.AI.Workflows.IWorkflowContext,System.Threading.Tasks.ValueTask<TResult>> handler, bool overwrite = false);
member this.AddHandler : Func<'Input, Microsoft.Agents.AI.Workflows.IWorkflowContext, System.Threading.Tasks.ValueTask<'Result>> * bool -> Microsoft.Agents.AI.Workflows.RouteBuilder
Public Function AddHandler(Of TInput, TResult) (handler As Func(Of TInput, IWorkflowContext, ValueTask(Of TResult)), Optional overwrite As Boolean = false) As RouteBuilder
Type Parameters
- TInput
The type of input message the handler will process.
- TResult
The type of result produced by the handler.
Parameters
- handler
- Func<TInput,IWorkflowContext,ValueTask<TResult>>
A function that processes messages of type TInput within the workflow context and returns
a ValueTask<TResult> representing the asynchronous result.
- overwrite
- Boolean
Set true to replace an existing handler for the specified input type; if no
handler is registered will throw. If set to false and a handler is registered, this will throw.
Returns
The current RouteBuilder instance, enabling fluent configuration of workflow routes.
Exceptions
If a handler is already registered for the specified type, and overwrite is set
to false, or if a handler is not already registered, but overwrite is set to true.
Remarks
If a handler for the given input type already exists, setting overwrite to true will replace the existing handler; otherwise, an exception may be thrown. The handler receives the input message and workflow context, and returns a result asynchronously.
Applies to
AddHandler<TInput,TResult>(Func<TInput,IWorkflowContext,TResult>, Boolean)
Registers a handler function for messages of the specified input type in the workflow route.
public Microsoft.Agents.AI.Workflows.RouteBuilder AddHandler<TInput,TResult>(Func<TInput,Microsoft.Agents.AI.Workflows.IWorkflowContext,TResult> handler, bool overwrite = false);
member this.AddHandler : Func<'Input, Microsoft.Agents.AI.Workflows.IWorkflowContext, 'Result> * bool -> Microsoft.Agents.AI.Workflows.RouteBuilder
Public Function AddHandler(Of TInput, TResult) (handler As Func(Of TInput, IWorkflowContext, TResult), Optional overwrite As Boolean = false) As RouteBuilder
Type Parameters
- TInput
The type of input message the handler will process.
- TResult
The type of result produced by the handler.
Parameters
- handler
- Func<TInput,IWorkflowContext,TResult>
A function that processes messages of type TInput within the workflow context and returns
a ValueTask<TResult> representing the asynchronous result.
- overwrite
- Boolean
Set true to replace an existing handler for the specified input type; if no
handler is registered will throw. If set to false and a handler is registered, this will throw.
Returns
The current RouteBuilder instance, enabling fluent configuration of workflow routes.
Exceptions
If a handler is already registered for the specified type, and overwrite is set
to false, or if a handler is not already registered, but overwrite is set to true.
Remarks
If a handler for the given input type already exists, setting overwrite to true will replace the existing handler; otherwise, an exception may be thrown. The handler receives the input message and workflow context, and returns a result asynchronously.
Applies to
AddHandler<TInput>(Action<TInput,IWorkflowContext,CancellationToken>, Boolean)
Registers a handler for messages of the specified input type in the workflow route.
public Microsoft.Agents.AI.Workflows.RouteBuilder AddHandler<TInput>(Action<TInput,Microsoft.Agents.AI.Workflows.IWorkflowContext,System.Threading.CancellationToken> handler, bool overwrite = false);
member this.AddHandler : Action<'Input, Microsoft.Agents.AI.Workflows.IWorkflowContext, System.Threading.CancellationToken> * bool -> Microsoft.Agents.AI.Workflows.RouteBuilder
Public Function AddHandler(Of TInput) (handler As Action(Of TInput, IWorkflowContext, CancellationToken), Optional overwrite As Boolean = false) As RouteBuilder
Type Parameters
- TInput
Parameters
- handler
- Action<TInput,IWorkflowContext,CancellationToken>
A delegate that processes messages of type TInput within the workflow context. The
delegate is invoked for each incoming message of the specified type.
- overwrite
- Boolean
Set true to replace an existing handler for the specified input type; if no
handler is registered will throw. If set to false and a handler is registered, this will throw.
Returns
The current RouteBuilder instance, enabling fluent configuration of additional handlers or route options.
Exceptions
If a handler is already registered for the specified type, and overwrite is set
to false, or if a handler is not already registered, but overwrite is set to true.
Remarks
If a handler for the specified input type already exists and overwrite is false, the existing handler will not be replaced. Handlers are invoked asynchronously and are expected to complete their processing before the workflow continues.
Applies to
AddHandler<TInput>(Action<TInput,IWorkflowContext>, Boolean)
Registers a handler for messages of the specified input type in the workflow route.
public Microsoft.Agents.AI.Workflows.RouteBuilder AddHandler<TInput>(Action<TInput,Microsoft.Agents.AI.Workflows.IWorkflowContext> handler, bool overwrite = false);
member this.AddHandler : Action<'Input, Microsoft.Agents.AI.Workflows.IWorkflowContext> * bool -> Microsoft.Agents.AI.Workflows.RouteBuilder
Public Function AddHandler(Of TInput) (handler As Action(Of TInput, IWorkflowContext), Optional overwrite As Boolean = false) As RouteBuilder
Type Parameters
- TInput
Parameters
- handler
- Action<TInput,IWorkflowContext>
A delegate that processes messages of type TInput within the workflow context. The
delegate is invoked for each incoming message of the specified type.
- overwrite
- Boolean
Set true to replace an existing handler for the specified input type; if no
handler is registered will throw. If set to false and a handler is registered, this will throw.
Returns
The current RouteBuilder instance, enabling fluent configuration of additional handlers or route options.
Exceptions
If a handler is already registered for the specified type, and overwrite is set
to false, or if a handler is not already registered, but overwrite is set to true.
Remarks
If a handler for the specified input type already exists and overwrite is false, the existing handler will not be replaced. Handlers are invoked asynchronously and are expected to complete their processing before the workflow continues.
Applies to
AddHandler<TInput>(Func<TInput,IWorkflowContext,CancellationToken,ValueTask>, Boolean)
Registers a handler for messages of the specified input type in the workflow route.
public Microsoft.Agents.AI.Workflows.RouteBuilder AddHandler<TInput>(Func<TInput,Microsoft.Agents.AI.Workflows.IWorkflowContext,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask> handler, bool overwrite = false);
member this.AddHandler : Func<'Input, Microsoft.Agents.AI.Workflows.IWorkflowContext, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask> * bool -> Microsoft.Agents.AI.Workflows.RouteBuilder
Public Function AddHandler(Of TInput) (handler As Func(Of TInput, IWorkflowContext, CancellationToken, ValueTask), Optional overwrite As Boolean = false) As RouteBuilder
Type Parameters
- TInput
Parameters
- handler
- Func<TInput,IWorkflowContext,CancellationToken,ValueTask>
A delegate that processes messages of type TInput within the workflow context. The
delegate is invoked for each incoming message of the specified type.
- overwrite
- Boolean
Set true to replace an existing handler for the specified input type; if no
handler is registered will throw. If set to false and a handler is registered, this will throw.
Returns
The current RouteBuilder instance, enabling fluent configuration of additional handlers or route options.
Exceptions
If a handler is already registered for the specified type, and overwrite is set
to false, or if a handler is not already registered, but overwrite is set to true.
Remarks
If a handler for the specified input type already exists and overwrite is false, the existing handler will not be replaced. Handlers are invoked asynchronously and are expected to complete their processing before the workflow continues.
Applies to
AddHandler<TInput>(Func<TInput,IWorkflowContext,ValueTask>, Boolean)
Registers a handler for messages of the specified input type in the workflow route.
public Microsoft.Agents.AI.Workflows.RouteBuilder AddHandler<TInput>(Func<TInput,Microsoft.Agents.AI.Workflows.IWorkflowContext,System.Threading.Tasks.ValueTask> handler, bool overwrite = false);
member this.AddHandler : Func<'Input, Microsoft.Agents.AI.Workflows.IWorkflowContext, System.Threading.Tasks.ValueTask> * bool -> Microsoft.Agents.AI.Workflows.RouteBuilder
Public Function AddHandler(Of TInput) (handler As Func(Of TInput, IWorkflowContext, ValueTask), Optional overwrite As Boolean = false) As RouteBuilder
Type Parameters
- TInput
Parameters
- handler
- Func<TInput,IWorkflowContext,ValueTask>
A delegate that processes messages of type TInput within the workflow context. The
delegate is invoked for each incoming message of the specified type.
- overwrite
- Boolean
Set true to replace an existing handler for the specified input type; if no
handler is registered will throw. If set to false and a handler is registered, this will throw.
Returns
The current RouteBuilder instance, enabling fluent configuration of additional handlers or route options.
Exceptions
If a handler is already registered for the specified type, and overwrite is set
to false, or if a handler is not already registered, but overwrite is set to true.
Remarks
If a handler for the specified input type already exists and overwrite is false, the existing handler will not be replaced. Handlers are invoked asynchronously and are expected to complete their processing before the workflow continues.