# ScheduledTask.Race(IReadOnlyList&lt;ScheduledTask&lt;TResult&gt;&gt;, CancellationToken)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask/methods/)

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

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

- `tasks` (`IReadOnlyList<ScheduledTask<TResult>>`): The tasks, which are captured when this method is called.
- `cancellationToken` (`CancellationToken`): 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](/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 the winner and the other tasks.

### Exceptions

- `System.ArgumentOutOfRangeException`: `tasks` is empty.
