TaskActivity<TInput,TOutput> Class
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.
Base class for activity implementations.
public abstract class TaskActivity<TInput,TOutput> : Microsoft.DurableTask.ITaskActivity
type TaskActivity<'Input, 'Output> = class
interface ITaskActivity
Public MustInherit Class TaskActivity(Of TInput, TOutput)
Implements ITaskActivity
Type Parameters
- TInput
The type of the input parameter that this activity accepts.
- TOutput
The type of the return value that this activity produces.
- Inheritance
-
TaskActivity<TInput,TOutput>
- Implements
Remarks
Activities are the basic unit of work in a durable task orchestration. Activities are the tasks that are orchestrated in the business process. For example, you might create an orchestrator to process an order. The tasks may involve checking the inventory, charging the customer, and creating a shipment. Each task would be a separate activity. These activities may be executed serially, in parallel, or some combination of both.
Unlike task orchestrators, activities aren't restricted in the type of work you can do in them. Activity functions are frequently used to make network calls or run CPU intensive operations. An activity can also return data back to the orchestrator function. The Durable Task runtime guarantees that each called activity function will be executed at least once during an orchestration's execution.
Because activities only guarantee at least once execution, it's recommended that activity logic be implemented as idempotent whenever possible.
Activities are invoked by orchestrators using one of the CallActivityAsync(TaskName, Object, TaskOptions) method overloads. Activities that derive from TaskActivity<TInput,TOutput> can also be invoked using generated extension methods. To participate in code generation, an activity class must be decorated with the DurableTaskAttribute attribute. The source generator will then generate a CallMyActivityAsync()
extension method for an activity named "MyActivity". The generated input parameter and return value will be derived from TInput
and TOutput
respectively.
Constructors
TaskActivity<TInput,TOutput>() |
Methods
RunAsync(TaskActivityContext, TInput) |
Override to implement async (non-blocking) task activity logic. |
Explicit Interface Implementations
ITaskActivity.InputType |
Gets the type of the input parameter that this activity accepts. |
ITaskActivity.OutputType |
Gets the type of the return value that this activity produces. |
ITaskActivity.RunAsync(TaskActivityContext, Object) |
Invokes the task activity with the specified context and input. |