Język

TaskDefinition<TInput,TOutput> Class

Definition

A typed handle to a registered resilient task, returned by AddResilientTask<TInput,TOutput>(IServiceCollection, String, Func<TaskContext<TInput>, CancellationToken,Task<TOutput>>, Action<TaskRegistrationOptions>) and AddResilientMultiTurnTask<TInput,TOutput>(IServiceCollection, String, Func<TaskContext<TInput>,CancellationToken,Task<TOutput>>, Boolean, Action<TaskRegistrationOptions>). The task name and its TInput/TOutput types are bound once at registration, so starting or running the task is strongly typed — an input or output that does not match the registration is a compile-time error rather than a runtime failure. The protected constructor and virtual members support substitution in consumer unit tests.

public class TaskDefinition<TInput,TOutput>
type TaskDefinition<'Input, 'Output> = class
Public Class TaskDefinition(Of TInput, TOutput)

Type Parameters

TInput

The task input type.

TOutput

The task output type.

Inheritance
TaskDefinition<TInput,TOutput>

Constructors

Name Description
TaskDefinition<TInput,TOutput>()

Initializes a new instance of the TaskDefinition<TInput,TOutput> class for mocking.

Properties

Name Description
Name

The registered task name.

Methods

Name Description
DeleteAsync(String, CancellationToken)

Ends a multi-turn chain: cancels any in-flight turn, resolves queued callers as cancelled, and removes the record. Idempotent — a no-op when the chain is absent.

GetActiveRunAsync(String, CancellationToken)

Returns the in-flight run for a one-shot task keyed by taskId, or null when not in-flight in this process and not reclaimable inline.

GetActiveRunAsync(String, String, CancellationToken)

Returns the in-flight run for a multi-turn task keyed by taskId and inputId, or null when not in-flight.

RunAsync(TInput, RunOptions, CancellationToken)

Starts the task and awaits it to completion, returning the typed result.

StartAsync(TInput, RunOptions, CancellationToken)

Starts the task and returns an awaitable handle once the creation round-trip succeeds.

Applies to