Skip to content

ScheduledTask<TResult> Methods

Represents a host-scheduled durable task with a result.

GetAwaiter

View source
public ScheduledTaskAwaiter<TResult> GetAwaiter()
Gets an awaiter which returns the successful result.

GetResult

View source
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)

View source
public bool TryGetResult(out TResult value)
Gets the result, when this handle has observed that the task completed successfully.

Parameters

valueTResult
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)

View source
public ConfiguredScheduledTaskAwaitable<TResult> WaitAsync(CancellationToken cancellationToken = default(CancellationToken))
Configures a typed wait with a wait-cancellation token.

Parameters

cancellationTokenCancellationToken

WaitAsync(TimeSpan, CancellationToken)

View source
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

timeoutTimeSpan
The time to wait before requesting cancellation, which is zero or positive.
cancellationTokenCancellationToken
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 accepts.
System.TimeoutException
The timeout elapsed, and the task ended canceled.

WaitUntilAsync(DateTimeOffset, CancellationToken)

View source
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

dueTimeDateTimeOffset
The time at which to request cancellation. A time which has passed times out promptly.
cancellationTokenCancellationToken
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 accepts.
System.TimeoutException
The due time passed, and the task ended canceled.