Skip to content

ScheduledTask.Race(IReadOnlyList<ScheduledTask<TResult>>, CancellationToken)

Race(IReadOnlyList<ScheduledTask<TResult>>, CancellationToken)

static
View source
public static Task<ScheduledTask<TResult>> Race<TResult>(IReadOnlyList<ScheduledTask<TResult>> tasks, CancellationToken cancellationToken = default(CancellationToken))
Waits for the first scheduled task to complete, requests durable cancellation of every other task, waits until every task is terminal, and returns the first task.

Parameters

tasksIReadOnlyList<ScheduledTask<TResult>>
The tasks, which are captured when this method is called.
cancellationTokenCancellationToken
A token which abandons the wait. It doesn't cancel the tasks.

Returns

The task which completed first, including a task which failed or was canceled. Every task has observed its terminal response, so ScheduledTask, ScheduledTask, and Orleans.Durable.Tasks.ScheduledTask.TryGetResult inspect the winner and the other tasks.

Exceptions

System.ArgumentOutOfRangeException
tasks is empty.