Επεξεργασία

Κοινή χρήση μέσω


TimeProviderTaskExtensions.Delay Method

Definition

Creates a task that completes after a specified time interval.

public static System.Threading.Tasks.Task Delay (this TimeProvider timeProvider, TimeSpan delay, System.Threading.CancellationToken cancellationToken = default);
static member Delay : TimeProvider * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function Delay (timeProvider As TimeProvider, delay As TimeSpan, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

timeProvider
TimeProvider

The TimeProvider with which to interpret delay.

delay
TimeSpan

The TimeSpan to wait before completing the returned task, or InfiniteTimeSpan to wait indefinitely.

cancellationToken
CancellationToken

A cancellation token to observe while waiting for the task to complete.

Returns

A task that represents the time delay.

Exceptions

The timeProvider argument is null.

delay represents a negative time interval other than InfiniteTimeSpan.

Applies to