System.Threading.Tasks.Task.Delay Method

Creates a task that will complete after a time delay.

Syntax

public static Task Delay (TimeSpan delay, System.Threading.CancellationToken cancellationToken)

Parameters

delay
The time span to wait before completing the returned task
cancellationToken
The cancellation token that will be checked prior to completing the returned task

Returns

A task that represents the time delay

Remarks

If the cancellation token is signaled before the specified time delay, then the task is completed in TaskStatus.Canceled state. Otherwise, the task is completed in TaskStatus.RanToCompletion state once the specified time delay has expired.

Requirements

Namespace: System.Threading.Tasks
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 4.0.0.0