Skip to content

ScheduledTask<TResult>.WaitUntilAsync(DateTimeOffset, CancellationToken)

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.