System.Threading.Tasks.Task.Delay Method

Creates a task that will complete after a time delay.

Syntax

public static Task Delay (int millisecondsDelay, System.Threading.CancellationToken cancellationToken)

Parameters

millisecondsDelay
The number of milliseconds 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 Canceled state. Otherwise, the task is completed in 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