# ScheduledTask&lt;TResult&gt; Methods

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

## GetAwaiter {#getawaiter-5f34b50d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask-1/methods/getawaiter-5f34b50d/)

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

```csharp
public ScheduledTaskAwaiter<TResult> GetAwaiter()
```

Gets an awaiter which returns the successful result.

## GetResult {#getresult-74081a08}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask-1/methods/getresult-74081a08/)

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

```csharp
public TResult GetResult()
```

Returns the result which this handle observed, or throws the recorded failure or cancellation, as awaiting the task does.

### Returns

The task's successful result.

### Exceptions

- `System.InvalidOperationException`: This handle hasn't observed the task's terminal response.

## TryGetResult(TResult) {#trygetresult-out-tresult-32da7858}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask-1/methods/trygetresult-out-tresult-32da7858/)

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

```csharp
public bool TryGetResult(out TResult value)
```

Gets the result, when this handle has observed that the task completed successfully.

### Parameters

- `value` (`TResult`): The successful result, or `default`.

### Returns

`true` when this handle observed a successful completion; otherwise `false`, for a task which failed, was canceled, or whose terminal response this handle hasn't observed.

## WaitAsync(CancellationToken) {#waitasync-system-threading-cancellationtoken-cdef4391}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask-1/methods/waitasync-system-threading-cancellationtoken-cdef4391/)

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

```csharp
public ConfiguredScheduledTaskAwaitable<TResult> WaitAsync(CancellationToken cancellationToken = default(CancellationToken))
```

Configures a typed wait with a wait-cancellation token.

### Parameters

- `cancellationToken` (`CancellationToken`)

## WaitAsync(TimeSpan, CancellationToken) {#waitasync-system-timespan-system-threading-cancellationtoken-9701d56a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask-1/methods/waitasync-system-timespan-system-threading-cancellationtoken-9701d56a/)

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

```csharp
public Task<TResult> WaitAsync(TimeSpan timeout, CancellationToken cancellationToken = default(CancellationToken))
```

Waits for and returns the successful result, and requests durable cancellation of the task once `timeout` elapses.

### Parameters

- `timeout` (`TimeSpan`): The time to wait before requesting cancellation, which is zero or positive.
- `cancellationToken` (`CancellationToken`): A token which abandons the wait. It doesn't cancel the task.

### Returns

The task's result, including a result which it returns after observing the timeout's cancellation request.

### Exceptions

- `System.ArgumentOutOfRangeException`: `timeout` is negative, including `System.Threading.Timeout.InfiniteTimeSpan`; await the task to wait without a timeout. Outside a durable execution, `timeout` also exceeds the longest timer interval which `System.Threading.CancellationTokenSource.CancelAfter(System.TimeSpan)` accepts.
- `System.TimeoutException`: The timeout elapsed, and the task ended canceled.

## WaitUntilAsync(DateTimeOffset, CancellationToken) {#waituntilasync-system-datetimeoffset-system-threading-cancellationtoken-da01c1c7}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.scheduledtask-1/methods/waituntilasync-system-datetimeoffset-system-threading-cancellationtoken-da01c1c7/)

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

```csharp
public Task<TResult> WaitUntilAsync(DateTimeOffset dueTime, CancellationToken cancellationToken = default(CancellationToken))
```

Waits for and returns the successful result, and requests durable cancellation of the task once `dueTime` passes.

### Parameters

- `dueTime` (`DateTimeOffset`): The time at which to request cancellation. A time which has passed times out promptly.
- `cancellationToken` (`CancellationToken`): A token which abandons the wait. It doesn't cancel the task.

### Returns

The task's result, including a result which it returns after observing the deadline's cancellation request.

### Exceptions

- `System.ArgumentOutOfRangeException`: Outside a durable execution, the time until `dueTime` exceeds the longest timer interval which `System.Threading.CancellationTokenSource.CancelAfter(System.TimeSpan)` accepts.
- `System.TimeoutException`: The due time passed, and the task ended canceled.
