Skip to content

DurableTask Methods

Defines a deferred, host-scheduled durable asynchronous operation.

Delay(TimeSpan)

static
View source
public static DurableTask Delay(TimeSpan duration)
Creates a durable delay measured using host logical time.

Parameters

durationTimeSpan

DelayUntil(DateTimeOffset)

static
View source
public static DurableTask DelayUntil(DateTimeOffset dueTime)
Creates a durable delay which completes at dueTime, measured using host logical time.

Parameters

dueTimeDateTimeOffset

FromResult(TResult)

static
View source
public static DurableTask<TResult> FromResult<TResult>(TResult value)
Creates a successfully completed durable task.

Parameters

valueTResult

GetVersion(string, int, int)

static
View source
public static int GetVersion(string name, int minSupported, int maxSupported)
Returns the version of the change name which the running durable task follows, so code which changes a workflow keeps replaying the executions which started before the change.

Parameters

namestring
The change's name within the running task, such as "carrier-api". Every call with the same name in one execution returns the same version. Names don't contain $.
minSupportedint
The oldest version which the calling code still supports. Version 0 is the code before the change's first version.
maxSupportedint
The newest version, which executions that reach the call for the first time record.

Returns

A version from minSupported to maxSupported.

Exceptions

System.ArgumentNullException
name is null.
System.ArgumentException
name is empty or contains $.
System.ArgumentOutOfRangeException
minSupported is negative, or maxSupported is less than minSupported.
Orleans.Durable.Tasks.DurableTaskAttemptCanceledException
The host canceled the attempt, for example because the execution recorded a version outside the supported range, which stalls it; the exception's inner exception is then a DurableTaskVersionException.
System.InvalidOperationException
The host can't record the version from the calling code, for example after ConfigureAwait(false).
System.NotSupportedException
The host doesn't support versions.

Examples

var version = DurableTask.GetVersion("carrier-api", minSupported: 0, maxSupported: 1);
if (version >= 1)
{
await carrier.BookAsync(order).WithId("book");
}
else
{
await legacyShipping.ShipAsync(order).WithId("ship");
}

Race(IEnumerable<DurableTask<TResult>>)

static
View source
public static DurableTask<(int Index, TResult Result)> DurableTask.Race<TResult>(IEnumerable<DurableTask<TResult>> tasks)
Creates a durable task which returns the input index and result of the first input task to complete, after requesting cancellation of every other input and waiting until each is terminal.

Parameters

tasksIEnumerable<DurableTask<TResult>>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution.

Exceptions

System.ArgumentOutOfRangeException
tasks is empty.

Race(IReadOnlyList<DurableTask<TResult>>)

static
View source
public static DurableTask<(int Index, TResult Result)> DurableTask.Race<TResult>(IReadOnlyList<DurableTask<TResult>> tasks)
Creates a durable task which returns the input index and result of the first input task to complete, after requesting cancellation of every other input and waiting until each is terminal.

Parameters

tasksIReadOnlyList<DurableTask<TResult>>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution.

Exceptions

System.ArgumentOutOfRangeException
tasks is empty.

Race(IEnumerable<DurableTask>)

static
View source
public static DurableTask<int> Race(IEnumerable<DurableTask> tasks)
Creates a durable task which returns the input index of the first input task to complete, after requesting cancellation of every other input and waiting until each is terminal.

Parameters

tasksIEnumerable<DurableTask>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution.

Exceptions

System.ArgumentOutOfRangeException
tasks is empty.

Race(IReadOnlyList<DurableTask>)

static
View source
public static DurableTask<int> Race(IReadOnlyList<DurableTask> tasks)
Creates a durable task which returns the input index of the first input task to complete, after requesting cancellation of every other input and waiting until each is terminal.

Parameters

tasksIReadOnlyList<DurableTask>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution.

Exceptions

System.ArgumentOutOfRangeException
tasks is empty.

Run(Action<CancellationToken>)

static
View source
public static DurableTask Run(Action<CancellationToken> action)
Creates an unstarted step which runs action as a child execution when it is awaited, scheduled, or posted.

Parameters

actionAction<CancellationToken>

Run(Func<CancellationToken, DurableTask>)

static
View source
[System.Obsolete(DurableTask.Run runs a delegate as a durable child, and a durable task already runs as one. Await the durable task directly., True)]
public static DurableTask Run(Func<CancellationToken, DurableTask> function)
Rejects a delegate which returns a durable task, which runs as a durable child when it is awaited.

Parameters

functionFunc<CancellationToken, DurableTask>

Run(Func<CancellationToken, Task>)

static
View source
public static DurableTask Run(Func<CancellationToken, Task> function)
Creates an unstarted step which runs asynchronous function as a child execution when it is awaited, scheduled, or posted.

Parameters

functionFunc<CancellationToken, Task>

Run(Func<DurableTask>)

static
View source
[System.Obsolete(DurableTask.Run runs a delegate as a durable child, and a durable task already runs as one. Await the durable task directly., True)]
public static DurableTask Run(Func<DurableTask> function)
Rejects a delegate which returns a durable task, which runs as a durable child when it is awaited.

Parameters

functionFunc<DurableTask>

Run(Func<Task>)

static
View source
public static DurableTask Run(Func<Task> function)
Creates an unstarted step which runs asynchronous function as a child execution when it is awaited, scheduled, or posted.

Parameters

functionFunc<Task>
The asynchronous function which the child runs.

Returns

A definition which runs the function each time it is awaited, scheduled, or posted.

Exceptions

System.ArgumentNullException
function is null.

Run(Func<ValueTask>)

static
View source
public static DurableTask Run(Func<ValueTask> function)
Creates an unstarted step which runs asynchronous function as a child execution when it is awaited, scheduled, or posted.

Parameters

functionFunc<ValueTask>
The asynchronous function which the child runs.

Returns

A definition which runs the function each time it is awaited, scheduled, or posted.

Exceptions

System.ArgumentNullException
function is null.

Run(Func<TState, CancellationToken, Task>, TState)

static
View source
public static DurableTask Run<TState>(Func<TState, CancellationToken, Task> function, TState state)
Creates a durable task which invokes asynchronous function with captured state.

Parameters

functionFunc<TState, CancellationToken, Task>
stateTState

Run(Func<CancellationToken, DurableTask<TResult>>)

static
View source
[System.Obsolete(DurableTask.Run runs a delegate as a durable child, and a durable task already runs as one. Await the durable task directly., True)]
public static DurableTask<TResult> Run<TResult>(Func<CancellationToken, DurableTask<TResult>> function)
Rejects a delegate which returns a durable task, which runs as a durable child when it is awaited.

Parameters

functionFunc<CancellationToken, DurableTask<TResult>>

Run(Func<CancellationToken, TResult>)

static
View source
public static DurableTask<TResult> Run<TResult>(Func<CancellationToken, TResult> function)
Creates an unstarted step which runs function as a child execution when it is awaited, scheduled, or posted.

Parameters

functionFunc<CancellationToken, TResult>

Run(Func<CancellationToken, Task<TResult>>)

static
View source
public static DurableTask<TResult> Run<TResult>(Func<CancellationToken, Task<TResult>> function)
Creates an unstarted step which runs asynchronous function as a child execution when it is awaited, scheduled, or posted.

Parameters

functionFunc<CancellationToken, Task<TResult>>

Run(Func<DurableTask<TResult>>)

static
View source
[System.Obsolete(DurableTask.Run runs a delegate as a durable child, and a durable task already runs as one. Await the durable task directly., True)]
public static DurableTask<TResult> Run<TResult>(Func<DurableTask<TResult>> function)
Rejects a delegate which returns a durable task, which runs as a durable child when it is awaited.

Parameters

functionFunc<DurableTask<TResult>>

Run(Func<Task<TResult>>)

static
View source
public static DurableTask<TResult> Run<TResult>(Func<Task<TResult>> function)
Creates an unstarted step. It runs function when it is awaited, scheduled, or posted, possibly in a later turn, as a child execution with its own DurableTask and cancellation scope. Unlike System.Threading.Tasks.Task.Run, creating it starts nothing, and nothing runs on the thread pool.

Parameters

functionFunc<Task<TResult>>
The asynchronous function which the child runs.

Returns

A definition which runs the function each time it is awaited, scheduled, or posted.

Exceptions

System.ArgumentNullException
function is null.

Run(Func<ValueTask<TResult>>)

static
View source
public static DurableTask<TResult> Run<TResult>(Func<ValueTask<TResult>> function)
Creates an unstarted step which runs asynchronous function as a child execution when it is awaited, scheduled, or posted.

Parameters

functionFunc<ValueTask<TResult>>
The asynchronous function which the child runs.

Returns

A definition which runs the function each time it is awaited, scheduled, or posted.

Exceptions

System.ArgumentNullException
function is null.

Run(Func<TState, CancellationToken, TResult>, TState)

static
View source
public static DurableTask<TResult> Run<TState, TResult>(Func<TState, CancellationToken, TResult> function, TState state)
Creates a durable task which invokes function with captured state.

Parameters

functionFunc<TState, CancellationToken, TResult>
stateTState

Run(Func<TState, CancellationToken, Task<TResult>>, TState)

static
View source
public static DurableTask<TResult> Run<TState, TResult>(Func<TState, CancellationToken, Task<TResult>> function, TState state)
Creates a durable task which invokes asynchronous function with captured state.

Parameters

functionFunc<TState, CancellationToken, Task<TResult>>
stateTState

RunAsync(DurableTaskContext)

abstract
protected internal abstract ValueTask<DurableTaskResponse> RunAsync(DurableTaskContext context)
Runs the definition in the supplied execution context.

Parameters

contextDurableTaskContext

RunInline(Func<DurableTask<TResult>>)

static
View source
[System.Obsolete(DurableTask.RunInline stores a synchronous result, and a durable task runs as a step. Await the durable task directly., True)]
public static TResult RunInline<TResult>(Func<DurableTask<TResult>> effect)
Rejects a durable task effect, which runs as a durable child when it is awaited.

Parameters

effectFunc<DurableTask<TResult>>

RunInline(Func<TResult>)

static
View source
public static TResult RunInline<TResult>(Func<TResult> effect)
Runs effect in the caller's current work item before returning, and records its outcome, which every later run of the task's body returns without running effect again.

Parameters

effectFunc<TResult>
The synchronous effect, which returns every value the body uses.

Returns

The result which the effect returned when it ran.

Exceptions

System.ArgumentNullException
effect is null.
System.InvalidOperationException
The host can't record the effect from the calling code, for example after ConfigureAwait(false).
Orleans.Durable.Tasks.DurableTaskAttemptCanceledException
The host canceled the attempt, for example with DurableTaskAttemptCancellationReason because an earlier run recorded another kind of operation, such as a step, under the effect's generated identifier.
System.NotSupportedException
TResult is an asynchronous operation, such as a System.Threading.Tasks.Task, a System.Threading.Tasks.ValueTask, or a DurableTask, or the host doesn't support recorded effects.

Examples

var paymentId = DurableTask.RunInline(Guid.NewGuid);

RunInline(Func<Task<TResult>>)

static
View source
[System.Obsolete(DurableTask.RunInline stores a synchronous result. For asynchronous work, use await DurableTask.Run(async () => ...)., True)]
public static TResult RunInline<TResult>(Func<Task<TResult>> effect)
Rejects an asynchronous effect, which DurableTask.RunInline can't record.

Parameters

effectFunc<Task<TResult>>

RunInline(Func<ValueTask<TResult>>)

static
View source
[System.Obsolete(DurableTask.RunInline stores a synchronous result. For asynchronous work, use await DurableTask.Run(async () => ...)., True)]
public static TResult RunInline<TResult>(Func<ValueTask<TResult>> effect)
Rejects an asynchronous effect, which DurableTask.RunInline can't record.

Parameters

effectFunc<ValueTask<TResult>>

RunInline(string, Func<DurableTask<TResult>>)

static
View source
[System.Obsolete(DurableTask.RunInline stores a synchronous result, and a durable task runs as a step. Await the durable task directly., True)]
public static TResult RunInline<TResult>(string name, Func<DurableTask<TResult>> effect)
Rejects a durable task effect, which runs as a durable child when it is awaited.

Parameters

namestring
effectFunc<DurableTask<TResult>>

RunInline(string, Func<TResult>)

static
View source
public static TResult RunInline<TResult>(string name, Func<TResult> effect)
Runs effect in the caller's current work item before returning, with no suspension and no child execution, and records its outcome in the same journal write as the journaled state which it changes. A replay returns the recorded outcome without running effect.

Parameters

namestring
The effect's name within the running task, which identifies the effect as WithId identifies a step: the first occurrence of a name in one run is name, and later occurrences append their order, such as name$2, so an effect in a loop keeps one name. Effects and steps share one count per name, and an earlier run's step under the effect's identifier is a divergence. Names don't contain $.
effectFunc<TResult>
The synchronous effect, which returns every value the body uses.

Returns

The result which the effect returned when it ran.

Exceptions

System.ArgumentNullException
name or effect is null.
System.ArgumentException
name is empty or contains $.
System.InvalidOperationException
The host can't record the effect from the calling code, for example after ConfigureAwait(false).
Orleans.Durable.Tasks.DurableTaskAttemptCanceledException
The host canceled the attempt, for example with DurableTaskAttemptCancellationReason because an earlier run recorded another kind of operation, such as a step, under the effect's identifier.
System.NotSupportedException
TResult is an asynchronous operation, such as a System.Threading.Tasks.Task, a System.Threading.Tasks.ValueTask, or a DurableTask, or the host doesn't support recorded effects.

Examples

var summary = DurableTask.RunInline("pay", () => SetStatus(OrderStatus.Paid));
var paymentId = DurableTask.RunInline("payment-id", Guid.NewGuid);

RunInline(string, Func<Task<TResult>>)

static
View source
[System.Obsolete(DurableTask.RunInline stores a synchronous result. For asynchronous work, use await DurableTask.Run(async () => ...)., True)]
public static TResult RunInline<TResult>(string name, Func<Task<TResult>> effect)
Rejects an asynchronous effect, which DurableTask.RunInline can't record.

Parameters

namestring
effectFunc<Task<TResult>>

RunInline(string, Func<ValueTask<TResult>>)

static
View source
[System.Obsolete(DurableTask.RunInline stores a synchronous result. For asynchronous work, use await DurableTask.Run(async () => ...)., True)]
public static TResult RunInline<TResult>(string name, Func<ValueTask<TResult>> effect)
Rejects an asynchronous effect, which DurableTask.RunInline can't record.

Parameters

namestring
effectFunc<ValueTask<TResult>>

RunInline(Action)

static
View source
public static void RunInline(Action effect)
Runs effect in the caller's current work item before returning, and records its outcome; later runs of the task's body don't run it again.

Parameters

effectAction
The synchronous effect.

Exceptions

System.ArgumentNullException
effect is null.
System.InvalidOperationException
The host can't record the effect from the calling code, for example after ConfigureAwait(false).
Orleans.Durable.Tasks.DurableTaskAttemptCanceledException
The host canceled the attempt, for example with DurableTaskAttemptCancellationReason because an earlier run recorded another kind of operation, such as a step, under the effect's generated identifier.
System.NotSupportedException
The host doesn't support recorded effects.

RunInline(Func<DurableTask>)

static
View source
[System.Obsolete(DurableTask.RunInline stores a synchronous result, and a durable task runs as a step. Await the durable task directly., True)]
public static void RunInline(Func<DurableTask> effect)
Rejects a durable task effect, which runs as a durable child when it is awaited.

Parameters

effectFunc<DurableTask>

RunInline(Func<Task>)

static
View source
[System.Obsolete(DurableTask.RunInline stores a synchronous result. For asynchronous work, use await DurableTask.Run(async () => ...)., True)]
public static void RunInline(Func<Task> effect)
Rejects an asynchronous effect, which DurableTask.RunInline can't record.

Parameters

effectFunc<Task>

RunInline(Func<ValueTask>)

static
View source
[System.Obsolete(DurableTask.RunInline stores a synchronous result. For asynchronous work, use await DurableTask.Run(async () => ...)., True)]
public static void RunInline(Func<ValueTask> effect)
Rejects an asynchronous effect, which DurableTask.RunInline can't record.

Parameters

effectFunc<ValueTask>

RunInline(string, Action)

static
View source
public static void RunInline(string name, Action effect)
Runs effect in the caller's current work item before returning, and records its outcome; later runs of the task's body don't run it again.

Parameters

namestring
The effect's name within the running task. A name repeated in one run identifies the effect's later occurrences by their order. Names don't contain $.
effectAction
The synchronous effect.

Exceptions

System.ArgumentNullException
name or effect is null.
System.ArgumentException
name is empty or contains $.
System.InvalidOperationException
The host can't record the effect from the calling code, for example after ConfigureAwait(false).
Orleans.Durable.Tasks.DurableTaskAttemptCanceledException
The host canceled the attempt, for example with DurableTaskAttemptCancellationReason because an earlier run recorded another kind of operation, such as a step, under the effect's identifier.
System.NotSupportedException
The host doesn't support recorded effects.

RunInline(string, Func<DurableTask>)

static
View source
[System.Obsolete(DurableTask.RunInline stores a synchronous result, and a durable task runs as a step. Await the durable task directly., True)]
public static void RunInline(string name, Func<DurableTask> effect)
Rejects a durable task effect, which runs as a durable child when it is awaited.

Parameters

namestring
effectFunc<DurableTask>

RunInline(string, Func<Task>)

static
View source
[System.Obsolete(DurableTask.RunInline stores a synchronous result. For asynchronous work, use await DurableTask.Run(async () => ...)., True)]
public static void RunInline(string name, Func<Task> effect)
Rejects an asynchronous effect, which DurableTask.RunInline can't record.

Parameters

namestring
effectFunc<Task>

RunInline(string, Func<ValueTask>)

static
View source
[System.Obsolete(DurableTask.RunInline stores a synchronous result. For asynchronous work, use await DurableTask.Run(async () => ...)., True)]
public static void RunInline(string name, Func<ValueTask> effect)
Rejects an asynchronous effect, which DurableTask.RunInline can't record.

Parameters

namestring
effectFunc<ValueTask>

ScheduleAll(IEnumerable<DurableTask<TResult>>)

static
View source
public static DurableTask<ScheduledTask<TResult>[]> ScheduleAll<TResult>(IEnumerable<DurableTask<TResult>> tasks)
Creates a durable task which schedules every input task and returns their handles, in input order.

Parameters

tasksIEnumerable<DurableTask<TResult>>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution and returns each input's handle at its input index once the inputs are scheduled, without waiting for their results.

ScheduleAll(IReadOnlyList<DurableTask<TResult>>)

static
View source
public static DurableTask<ScheduledTask<TResult>[]> ScheduleAll<TResult>(IReadOnlyList<DurableTask<TResult>> tasks)
Creates a durable task which schedules every input task and returns their handles, in input order.

Parameters

tasksIReadOnlyList<DurableTask<TResult>>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution and returns each input's handle at its input index once the inputs are scheduled, without waiting for their results.

ScheduleAll(IEnumerable<DurableTask>)

static
View source
public static DurableTask<ScheduledTask[]> ScheduleAll(IEnumerable<DurableTask> tasks)
Creates a durable task which schedules every input task and returns their handles, in input order.

Parameters

tasksIEnumerable<DurableTask>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution and returns each input's handle at its input index once the inputs are scheduled, without waiting for their results.

ScheduleAll(IReadOnlyList<DurableTask>)

static
View source
public static DurableTask<ScheduledTask[]> ScheduleAll(IReadOnlyList<DurableTask> tasks)
Creates a durable task which schedules every input task and returns their handles, in input order.

Parameters

tasksIReadOnlyList<DurableTask>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution and returns each input's handle at its input index once the inputs are scheduled, without waiting for their results.

WhenAll(IEnumerable<DurableTask>)

static
View source
public static DurableTask WhenAll(IEnumerable<DurableTask> tasks)
Creates a durable task which completes once every input task has completed.

Parameters

tasksIEnumerable<DurableTask>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution.

WhenAll(IReadOnlyList<DurableTask>)

static
View source
public static DurableTask WhenAll(IReadOnlyList<DurableTask> tasks)
Creates a durable task which completes once every input task has completed.

Parameters

tasksIReadOnlyList<DurableTask>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution.

WhenAll(IEnumerable<DurableTask<TResult>>)

static
View source
public static DurableTask<TResult[]> WhenAll<TResult>(IEnumerable<DurableTask<TResult>> tasks)
Creates a durable task which returns the results of every input task, in input order.

Parameters

tasksIEnumerable<DurableTask<TResult>>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution and returns an array with each input's result at its input index.

WhenAll(IReadOnlyList<DurableTask<TResult>>)

static
View source
public static DurableTask<TResult[]> WhenAll<TResult>(IReadOnlyList<DurableTask<TResult>> tasks)
Creates a durable task which returns the results of every input task, in input order.

Parameters

tasksIReadOnlyList<DurableTask<TResult>>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution and returns an array with each input's result at its input index.

WhenAllCompleted(IEnumerable<DurableTask<TResult>>)

static
View source
public static DurableTask<ScheduledTask<TResult>[]> WhenAllCompleted<TResult>(IEnumerable<DurableTask<TResult>> tasks)
Creates a durable task which schedules every input task, waits until each is terminal, and returns their handles, in input order.

Parameters

tasksIEnumerable<DurableTask<TResult>>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution and returns each input's handle at its input index. Each handle has observed its terminal response, so ScheduledTask, ScheduledTask, and Orleans.Durable.Tasks.ScheduledTask.TryGetResult inspect it.

WhenAllCompleted(IReadOnlyList<DurableTask<TResult>>)

static
View source
public static DurableTask<ScheduledTask<TResult>[]> WhenAllCompleted<TResult>(IReadOnlyList<DurableTask<TResult>> tasks)
Creates a durable task which schedules every input task, waits until each is terminal, and returns their handles, in input order.

Parameters

tasksIReadOnlyList<DurableTask<TResult>>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution and returns each input's handle at its input index. Each handle has observed its terminal response, so ScheduledTask, ScheduledTask, and Orleans.Durable.Tasks.ScheduledTask.TryGetResult inspect it.

WhenAllCompleted(IEnumerable<DurableTask>)

static
View source
public static DurableTask<ScheduledTask[]> WhenAllCompleted(IEnumerable<DurableTask> tasks)
Creates a durable task which schedules every input task, waits until each is terminal, and returns their handles, in input order.

Parameters

tasksIEnumerable<DurableTask>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution and returns each input's handle at its input index. Each handle has observed its terminal response, so ScheduledTask, ScheduledTask, and Orleans.Durable.Tasks.ScheduledTask.TryGetResult inspect it.

WhenAllCompleted(IReadOnlyList<DurableTask>)

static
View source
public static DurableTask<ScheduledTask[]> WhenAllCompleted(IReadOnlyList<DurableTask> tasks)
Creates a durable task which schedules every input task, waits until each is terminal, and returns their handles, in input order.

Parameters

tasksIReadOnlyList<DurableTask>
The input tasks, which are captured when this method is called.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution and returns each input's handle at its input index. Each handle has observed its terminal response, so ScheduledTask, ScheduledTask, and Orleans.Durable.Tasks.ScheduledTask.TryGetResult inspect it.

WhenAny(IEnumerable<DurableTask<TResult>>)

static
View source
public static DurableTask<(int Index, TResult Result)> DurableTask.WhenAny<TResult>(IEnumerable<DurableTask<TResult>> tasks)
Creates a durable task which returns the input index and result of the first input task to complete.

Parameters

tasksIEnumerable<DurableTask<TResult>>
The input tasks.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution.

Exceptions

System.ArgumentOutOfRangeException
tasks is empty.

WhenAny(IReadOnlyList<DurableTask<TResult>>)

static
View source
public static DurableTask<(int Index, TResult Result)> DurableTask.WhenAny<TResult>(IReadOnlyList<DurableTask<TResult>> tasks)
Creates a durable task which returns the input index and result of the first input task to complete.

Parameters

tasksIReadOnlyList<DurableTask<TResult>>
The input tasks.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution.

Exceptions

System.ArgumentOutOfRangeException
tasks is empty.

WhenAny(IEnumerable<DurableTask>)

static
View source
public static DurableTask<int> WhenAny(IEnumerable<DurableTask> tasks)
Creates a durable task which returns the input index of the first input task to complete.

Parameters

tasksIEnumerable<DurableTask>
The input tasks.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution.

Exceptions

System.ArgumentOutOfRangeException
tasks is empty.

WhenAny(IReadOnlyList<DurableTask>)

static
View source
public static DurableTask<int> WhenAny(IReadOnlyList<DurableTask> tasks)
Creates a durable task which returns the input index of the first input task to complete.

Parameters

tasksIReadOnlyList<DurableTask>
The input tasks.

Returns

A combinator which, awaited within a durable execution, runs as part of that execution.

Exceptions

System.ArgumentOutOfRangeException
tasks is empty.

WhenEach(IEnumerable<DurableTask<TResult>>)

static
View source
public static IAsyncEnumerable<ScheduledTask<TResult>> WhenEach<TResult>(IEnumerable<DurableTask<TResult>> tasks)
Schedules every input task and yields each input's handle once, in completion order, as the input reaches a terminal state.

Parameters

tasksIEnumerable<DurableTask<TResult>>
The input tasks, which are captured when this method is called.

Returns

The inputs' handles in completion order. Each yielded handle has observed its terminal response, including a failure or a cancellation, which doesn't fail the enumeration.

Exceptions

System.InvalidOperationException
The method is called outside a durable execution.

WhenEach(IReadOnlyList<DurableTask<TResult>>)

static
View source
public static IAsyncEnumerable<ScheduledTask<TResult>> WhenEach<TResult>(IReadOnlyList<DurableTask<TResult>> tasks)
Schedules every input task and yields each input's handle once, in completion order, as the input reaches a terminal state.

Parameters

tasksIReadOnlyList<DurableTask<TResult>>
The input tasks, which are captured when this method is called.

Returns

The inputs' handles in completion order. Each yielded handle has observed its terminal response, including a failure or a cancellation, which doesn't fail the enumeration.

Exceptions

System.InvalidOperationException
The method is called outside a durable execution.

WhenEach(IEnumerable<DurableTask>)

static
View source
public static IAsyncEnumerable<ScheduledTask> WhenEach(IEnumerable<DurableTask> tasks)
Schedules every input task and yields each input's handle once, in completion order, as the input reaches a terminal state.

Parameters

tasksIEnumerable<DurableTask>
The input tasks, which are captured when this method is called.

Returns

The inputs' handles in completion order. Each yielded handle has observed its terminal response, including a failure or a cancellation, which doesn't fail the enumeration.

Exceptions

System.InvalidOperationException
The method is called outside a durable execution.

WhenEach(IReadOnlyList<DurableTask>)

static
View source
public static IAsyncEnumerable<ScheduledTask> WhenEach(IReadOnlyList<DurableTask> tasks)
Schedules every input task and yields each input's handle once, in completion order, as the input reaches a terminal state.

Parameters

tasksIReadOnlyList<DurableTask>
The input tasks, which are captured when this method is called.

Returns

The inputs' handles in completion order. Each yielded handle has observed its terminal response, including a failure or a cancellation, which doesn't fail the enumeration.

Exceptions

System.InvalidOperationException
The method is called outside a durable execution.