# DurableTask Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/)

## Delay(TimeSpan) {#delay-system-timespan-b45c3e83}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/delay-system-timespan-b45c3e83/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs#L29-L30)

```csharp
public static DurableTask Delay(TimeSpan duration)
```

Creates a durable delay measured using host logical time.

### Parameters

- `duration` (`TimeSpan`)

## DelayUntil(DateTimeOffset) {#delayuntil-system-datetimeoffset-c3520b89}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/delayuntil-system-datetimeoffset-c3520b89/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs#L35)

```csharp
public static DurableTask DelayUntil(DateTimeOffset dueTime)
```

Creates a durable delay which completes at `dueTime`, measured using host logical time.

### Parameters

- `dueTime` (`DateTimeOffset`)

## FromResult(TResult) {#fromresult-1-tresult-983cf9d6}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/fromresult-1-tresult-983cf9d6/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs#L24)

```csharp
public static DurableTask<TResult> FromResult<TResult>(TResult value)
```

Creates a successfully completed durable task.

### Parameters

- `value` (`TResult`)

## GetVersion(string, int, int) {#getversion-string-int-int-b5ee265a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/getversion-string-int-int-b5ee265a/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Version.cs#L84-L89)

```csharp
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

- `name` (`string`): 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 `$`.
- `minSupported` (`int`): The oldest version which the calling code still supports. Version `0` is the code before the change's first version.
- `maxSupported` (`int`): 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](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.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

```csharp
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&lt;DurableTask&lt;TResult&gt;&gt;) {#race-1-system-collections-generic-ienumerable-orleans-durable-tasks-durabletask-7b974e79}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/race-1-system-collections-generic-ienumerable-orleans-durable-tasks-durabletask-7b974e79/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Race.cs)

```csharp
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

- `tasks` (`IEnumerable<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&lt;DurableTask&lt;TResult&gt;&gt;) {#race-1-system-collections-generic-ireadonlylist-orleans-durable-tasks-durabletas-10a60575}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/race-1-system-collections-generic-ireadonlylist-orleans-durable-tasks-durabletas-10a60575/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Race.cs)

```csharp
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

- `tasks` (`IReadOnlyList<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&lt;DurableTask&gt;) {#race-system-collections-generic-ienumerable-orleans-durable-tasks-durabletask-9431a86e}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/race-system-collections-generic-ienumerable-orleans-durable-tasks-durabletask-9431a86e/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Race.cs)

```csharp
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

- `tasks` (`IEnumerable<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&lt;DurableTask&gt;) {#race-system-collections-generic-ireadonlylist-orleans-durable-tasks-durabletask-c2b0515a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/race-system-collections-generic-ireadonlylist-orleans-durable-tasks-durabletask-c2b0515a/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Race.cs)

```csharp
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

- `tasks` (`IReadOnlyList<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&lt;CancellationToken&gt;) {#run-system-action-system-threading-cancellationtoken-dc65fbfc}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-system-action-system-threading-cancellationtoken-dc65fbfc/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs#L40-L41)

```csharp
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

- `action` (`Action<CancellationToken>`)

## Run(Func&lt;CancellationToken, DurableTask&gt;) {#run-system-func-system-threading-cancellationtoken-orleans-durable-tasks-durable-dc0cfcae}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-system-func-system-threading-cancellationtoken-orleans-durable-tasks-durable-dc0cfcae/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
[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

- `function` (`Func<CancellationToken, DurableTask>`)

## Run(Func&lt;CancellationToken, Task&gt;) {#run-system-func-system-threading-cancellationtoken-system-threading-tasks-task-11627cf5}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-system-func-system-threading-cancellationtoken-system-threading-tasks-task-11627cf5/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
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

- `function` (`Func<CancellationToken, Task>`)

## Run(Func&lt;DurableTask&gt;) {#run-system-func-orleans-durable-tasks-durabletask-79e09948}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-system-func-orleans-durable-tasks-durabletask-79e09948/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
[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

- `function` (`Func<DurableTask>`)

## Run(Func&lt;Task&gt;) {#run-system-func-system-threading-tasks-task-0f229293}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-system-func-system-threading-tasks-task-0f229293/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
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

- `function` (`Func<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&lt;ValueTask&gt;) {#run-system-func-system-threading-tasks-valuetask-756f2322}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-system-func-system-threading-tasks-valuetask-756f2322/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
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

- `function` (`Func<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(Action&lt;TState, CancellationToken&gt;, TState) {#run-1-system-action-tstate-system-threading-cancellationtoken-tstate-e7fe32ac}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-1-system-action-tstate-system-threading-cancellationtoken-tstate-e7fe32ac/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs#L160-L161)

```csharp
public static DurableTask Run<TState>(Action<TState, CancellationToken> action, TState state)
```

Creates a durable task which invokes `action` with captured `state`.

### Parameters

- `action` (`Action<TState, CancellationToken>`)
- `state` (`TState`)

## Run(Func&lt;TState, CancellationToken, Task&gt;, TState) {#run-1-system-func-tstate-system-threading-cancellationtoken-system-threading-tas-1f51f1d9}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-1-system-func-tstate-system-threading-cancellationtoken-system-threading-tas-1f51f1d9/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
public static DurableTask Run<TState>(Func<TState, CancellationToken, Task> function, TState state)
```

Creates a durable task which invokes asynchronous `function` with captured `state`.

### Parameters

- `function` (`Func<TState, CancellationToken, Task>`)
- `state` (`TState`)

## Run(Func&lt;CancellationToken, DurableTask&lt;TResult&gt;&gt;) {#run-1-system-func-system-threading-cancellationtoken-orleans-durable-tasks-durab-2e28b7eb}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-1-system-func-system-threading-cancellationtoken-orleans-durable-tasks-durab-2e28b7eb/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
[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

- `function` (`Func<CancellationToken, DurableTask<TResult>>`)

## Run(Func&lt;CancellationToken, TResult&gt;) {#run-1-system-func-system-threading-cancellationtoken-tresult-8eee9e37}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-1-system-func-system-threading-cancellationtoken-tresult-8eee9e37/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
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

- `function` (`Func<CancellationToken, TResult>`)

## Run(Func&lt;CancellationToken, Task&lt;TResult&gt;&gt;) {#run-1-system-func-system-threading-cancellationtoken-system-threading-tasks-task-6be619e2}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-1-system-func-system-threading-cancellationtoken-system-threading-tasks-task-6be619e2/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
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

- `function` (`Func<CancellationToken, Task<TResult>>`)

## Run(Func&lt;DurableTask&lt;TResult&gt;&gt;) {#run-1-system-func-orleans-durable-tasks-durabletask-tresult-781171cd}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-1-system-func-orleans-durable-tasks-durabletask-tresult-781171cd/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
[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

- `function` (`Func<DurableTask<TResult>>`)

## Run(Func&lt;Task&lt;TResult&gt;&gt;) {#run-1-system-func-system-threading-tasks-task-tresult-4e696c80}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-1-system-func-system-threading-tasks-task-tresult-4e696c80/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
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](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/) and cancellation scope. Unlike `System.Threading.Tasks.Task.Run(System.Func{System.Threading.Tasks.Task})`, creating it starts nothing, and nothing runs on the thread pool.

### Parameters

- `function` (`Func<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&lt;ValueTask&lt;TResult&gt;&gt;) {#run-1-system-func-system-threading-tasks-valuetask-tresult-50310f4f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-1-system-func-system-threading-tasks-valuetask-tresult-50310f4f/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
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

- `function` (`Func<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&lt;TState, CancellationToken, TResult&gt;, TState) {#run-2-system-func-tstate-system-threading-cancellationtoken-tresult-tstate-548a95f3}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-2-system-func-tstate-system-threading-cancellationtoken-tresult-tstate-548a95f3/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
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

- `function` (`Func<TState, CancellationToken, TResult>`)
- `state` (`TState`)

## Run(Func&lt;TState, CancellationToken, Task&lt;TResult&gt;&gt;, TState) {#run-2-system-func-tstate-system-threading-cancellationtoken-system-threading-tas-6f4e9dfe}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/run-2-system-func-tstate-system-threading-cancellationtoken-system-threading-tas-6f4e9dfe/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.cs)

```csharp
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

- `function` (`Func<TState, CancellationToken, Task<TResult>>`)
- `state` (`TState`)

## RunAsync(DurableTaskContext) {#runasync-orleans-durable-tasks-durabletaskcontext-70487199}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runasync-orleans-durable-tasks-durabletaskcontext-70487199/)

```csharp
protected internal abstract ValueTask<DurableTaskResponse> RunAsync(DurableTaskContext context)
```

Runs the definition in the supplied execution context.

### Parameters

- `context` (`DurableTaskContext`)

## RunInline(Func&lt;DurableTask&lt;TResult&gt;&gt;) {#runinline-1-system-func-orleans-durable-tasks-durabletask-tresult-c4d7ab25}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-1-system-func-orleans-durable-tasks-durabletask-tresult-c4d7ab25/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
[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

- `effect` (`Func<DurableTask<TResult>>`)

## RunInline(Func&lt;TResult&gt;) {#runinline-1-system-func-tresult-53fc9823}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-1-system-func-tresult-53fc9823/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
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

- `effect` (`Func<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](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.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](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/), or the host doesn't support recorded effects.

### Examples

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

## RunInline(Func&lt;Task&lt;TResult&gt;&gt;) {#runinline-1-system-func-system-threading-tasks-task-tresult-e630808a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-1-system-func-system-threading-tasks-task-tresult-e630808a/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
[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

- `effect` (`Func<Task<TResult>>`)

## RunInline(Func&lt;ValueTask&lt;TResult&gt;&gt;) {#runinline-1-system-func-system-threading-tasks-valuetask-tresult-3262f2cf}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-1-system-func-system-threading-tasks-valuetask-tresult-3262f2cf/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
[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

- `effect` (`Func<ValueTask<TResult>>`)

## RunInline(string, Func&lt;DurableTask&lt;TResult&gt;&gt;) {#runinline-1-string-system-func-orleans-durable-tasks-durabletask-tresult-53ae3291}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-1-string-system-func-orleans-durable-tasks-durabletask-tresult-53ae3291/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
[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

- `name` (`string`)
- `effect` (`Func<DurableTask<TResult>>`)

## RunInline(string, Func&lt;TResult&gt;) {#runinline-1-string-system-func-tresult-98bb11af}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-1-string-system-func-tresult-98bb11af/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
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

- `name` (`string`): 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 `$`.
- `effect` (`Func<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](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.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](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/), or the host doesn't support recorded effects.

### Examples

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

## RunInline(string, Func&lt;Task&lt;TResult&gt;&gt;) {#runinline-1-string-system-func-system-threading-tasks-task-tresult-f649829e}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-1-string-system-func-system-threading-tasks-task-tresult-f649829e/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
[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

- `name` (`string`)
- `effect` (`Func<Task<TResult>>`)

## RunInline(string, Func&lt;ValueTask&lt;TResult&gt;&gt;) {#runinline-1-string-system-func-system-threading-tasks-valuetask-tresult-d77d3b5b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-1-string-system-func-system-threading-tasks-valuetask-tresult-d77d3b5b/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
[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

- `name` (`string`)
- `effect` (`Func<ValueTask<TResult>>`)

## RunInline(Action) {#runinline-system-action-49a7e1b6}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-system-action-49a7e1b6/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
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

- `effect` (`Action`): 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](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.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&lt;DurableTask&gt;) {#runinline-system-func-orleans-durable-tasks-durabletask-943d464e}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-system-func-orleans-durable-tasks-durabletask-943d464e/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
[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

- `effect` (`Func<DurableTask>`)

## RunInline(Func&lt;Task&gt;) {#runinline-system-func-system-threading-tasks-task-69f2d96f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-system-func-system-threading-tasks-task-69f2d96f/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
[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

- `effect` (`Func<Task>`)

## RunInline(Func&lt;ValueTask&gt;) {#runinline-system-func-system-threading-tasks-valuetask-ba846c38}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-system-func-system-threading-tasks-valuetask-ba846c38/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
[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

- `effect` (`Func<ValueTask>`)

## RunInline(string, Action) {#runinline-string-system-action-31937df2}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-string-system-action-31937df2/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
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

- `name` (`string`): 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 `$`.
- `effect` (`Action`): 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](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.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&lt;DurableTask&gt;) {#runinline-string-system-func-orleans-durable-tasks-durabletask-cce05fea}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-string-system-func-orleans-durable-tasks-durabletask-cce05fea/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
[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

- `name` (`string`)
- `effect` (`Func<DurableTask>`)

## RunInline(string, Func&lt;Task&gt;) {#runinline-string-system-func-system-threading-tasks-task-3d509093}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-string-system-func-system-threading-tasks-task-3d509093/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
[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

- `name` (`string`)
- `effect` (`Func<Task>`)

## RunInline(string, Func&lt;ValueTask&gt;) {#runinline-string-system-func-system-threading-tasks-valuetask-66f803e4}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/runinline-string-system-func-system-threading-tasks-valuetask-66f803e4/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.RunInline.cs)

```csharp
[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

- `name` (`string`)
- `effect` (`Func<ValueTask>`)

## ScheduleAll(IEnumerable&lt;DurableTask&lt;TResult&gt;&gt;) {#scheduleall-1-system-collections-generic-ienumerable-orleans-durable-tasks-durab-e460af47}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/scheduleall-1-system-collections-generic-ienumerable-orleans-durable-tasks-durab-e460af47/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IEnumerable<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&lt;DurableTask&lt;TResult&gt;&gt;) {#scheduleall-1-system-collections-generic-ireadonlylist-orleans-durable-tasks-dur-0b7743af}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/scheduleall-1-system-collections-generic-ireadonlylist-orleans-durable-tasks-dur-0b7743af/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IReadOnlyList<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&lt;DurableTask&gt;) {#scheduleall-system-collections-generic-ienumerable-orleans-durable-tasks-durable-e0b09ed0}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/scheduleall-system-collections-generic-ienumerable-orleans-durable-tasks-durable-e0b09ed0/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IEnumerable<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&lt;DurableTask&gt;) {#scheduleall-system-collections-generic-ireadonlylist-orleans-durable-tasks-durab-2138c008}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/scheduleall-system-collections-generic-ireadonlylist-orleans-durable-tasks-durab-2138c008/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IReadOnlyList<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&lt;DurableTask&gt;) {#whenall-system-collections-generic-ienumerable-orleans-durable-tasks-durabletask-ba509d7b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/whenall-system-collections-generic-ienumerable-orleans-durable-tasks-durabletask-ba509d7b/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
public static DurableTask WhenAll(IEnumerable<DurableTask> tasks)
```

Creates a durable task which completes once every input task has completed.

### Parameters

- `tasks` (`IEnumerable<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&lt;DurableTask&gt;) {#whenall-system-collections-generic-ireadonlylist-orleans-durable-tasks-durableta-d07651e3}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/whenall-system-collections-generic-ireadonlylist-orleans-durable-tasks-durableta-d07651e3/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
public static DurableTask WhenAll(IReadOnlyList<DurableTask> tasks)
```

Creates a durable task which completes once every input task has completed.

### Parameters

- `tasks` (`IReadOnlyList<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&lt;DurableTask&lt;TResult&gt;&gt;) {#whenall-1-system-collections-generic-ienumerable-orleans-durable-tasks-durableta-b05cb0d6}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/whenall-1-system-collections-generic-ienumerable-orleans-durable-tasks-durableta-b05cb0d6/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IEnumerable<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&lt;DurableTask&lt;TResult&gt;&gt;) {#whenall-1-system-collections-generic-ireadonlylist-orleans-durable-tasks-durable-d0eca5ce}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/whenall-1-system-collections-generic-ireadonlylist-orleans-durable-tasks-durable-d0eca5ce/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IReadOnlyList<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&lt;DurableTask&lt;TResult&gt;&gt;) {#whenallcompleted-1-system-collections-generic-ienumerable-orleans-durable-tasks-72aa8f1d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/whenallcompleted-1-system-collections-generic-ienumerable-orleans-durable-tasks-72aa8f1d/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IEnumerable<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](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask/), [ScheduledTask](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask/), and `Orleans.Durable.Tasks.ScheduledTask-1.TryGetResult(-0@)` inspect it.

## WhenAllCompleted(IReadOnlyList&lt;DurableTask&lt;TResult&gt;&gt;) {#whenallcompleted-1-system-collections-generic-ireadonlylist-orleans-durable-task-de3d8b09}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/whenallcompleted-1-system-collections-generic-ireadonlylist-orleans-durable-task-de3d8b09/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IReadOnlyList<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](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask/), [ScheduledTask](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask/), and `Orleans.Durable.Tasks.ScheduledTask-1.TryGetResult(-0@)` inspect it.

## WhenAllCompleted(IEnumerable&lt;DurableTask&gt;) {#whenallcompleted-system-collections-generic-ienumerable-orleans-durable-tasks-du-e4c7ec68}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/whenallcompleted-system-collections-generic-ienumerable-orleans-durable-tasks-du-e4c7ec68/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IEnumerable<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](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask/), [ScheduledTask](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask/), and `Orleans.Durable.Tasks.ScheduledTask-1.TryGetResult(-0@)` inspect it.

## WhenAllCompleted(IReadOnlyList&lt;DurableTask&gt;) {#whenallcompleted-system-collections-generic-ireadonlylist-orleans-durable-tasks-ab2445b0}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/whenallcompleted-system-collections-generic-ireadonlylist-orleans-durable-tasks-ab2445b0/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IReadOnlyList<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](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask/), [ScheduledTask](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask/), and `Orleans.Durable.Tasks.ScheduledTask-1.TryGetResult(-0@)` inspect it.

## WhenAny(IEnumerable&lt;DurableTask&lt;TResult&gt;&gt;) {#whenany-1-system-collections-generic-ienumerable-orleans-durable-tasks-durableta-fbb29f5a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/whenany-1-system-collections-generic-ienumerable-orleans-durable-tasks-durableta-fbb29f5a/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IEnumerable<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&lt;DurableTask&lt;TResult&gt;&gt;) {#whenany-1-system-collections-generic-ireadonlylist-orleans-durable-tasks-durable-9d0ccc02}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/whenany-1-system-collections-generic-ireadonlylist-orleans-durable-tasks-durable-9d0ccc02/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IReadOnlyList<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&lt;DurableTask&gt;) {#whenany-system-collections-generic-ienumerable-orleans-durable-tasks-durabletask-93577777}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/whenany-system-collections-generic-ienumerable-orleans-durable-tasks-durabletask-93577777/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IEnumerable<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&lt;DurableTask&gt;) {#whenany-system-collections-generic-ireadonlylist-orleans-durable-tasks-durableta-e66435df}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/whenany-system-collections-generic-ireadonlylist-orleans-durable-tasks-durableta-e66435df/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IReadOnlyList<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&lt;DurableTask&lt;TResult&gt;&gt;) {#wheneach-1-system-collections-generic-ienumerable-orleans-durable-tasks-durablet-637f7f4b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/wheneach-1-system-collections-generic-ienumerable-orleans-durable-tasks-durablet-637f7f4b/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IEnumerable<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&lt;DurableTask&lt;TResult&gt;&gt;) {#wheneach-1-system-collections-generic-ireadonlylist-orleans-durable-tasks-durabl-8b723af3}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/wheneach-1-system-collections-generic-ireadonlylist-orleans-durable-tasks-durabl-8b723af3/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IReadOnlyList<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&lt;DurableTask&gt;) {#wheneach-system-collections-generic-ienumerable-orleans-durable-tasks-durabletas-de941ec4}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/wheneach-system-collections-generic-ienumerable-orleans-durable-tasks-durabletas-de941ec4/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IEnumerable<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&lt;DurableTask&gt;) {#wheneach-system-collections-generic-ireadonlylist-orleans-durable-tasks-durablet-a1f2a48c}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/wheneach-system-collections-generic-ireadonlylist-orleans-durable-tasks-durablet-a1f2a48c/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Combinators.cs)

```csharp
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

- `tasks` (`IReadOnlyList<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.
