Skip to content

ScheduledTask.WaitAsync(TimeSpan, CancellationToken)

WaitAsync(TimeSpan, CancellationToken)

View source
public Task WaitAsync(TimeSpan timeout, CancellationToken cancellationToken = default(CancellationToken))
Waits for successful completion, 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

An operation which completes once the task is terminal.

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.