Task::Delay Method (Int32, CancellationToken)
Creates a cancellable task that completes after a time delay.
Assembly: mscorlib (in mscorlib.dll)
public: static Task^ Delay( int millisecondsDelay, CancellationToken cancellationToken )
The number of milliseconds to wait before completing the returned task, or -1 to wait indefinitely.
The cancellation token that will be checked prior to completing the returned task.
Return ValueType: System.Threading.Tasks::Task^
A task that represents the time delay.
If the cancellation token is signaled before the specified time delay, a TaskCanceledException exception results, and the task is completed in the TaskStatus::Canceled state. Otherwise, the task is completed in the TaskStatus::RanToCompletion state once the specified time delay has elapsed.
For usage scenarios and additional examples, see the documentation for the Delay(Int32) overload.
This method depends on the system clock. This means that the time delay will approximately equal the resolution of the system clock if the millisecondsDelay argument is less than the resolution of the system clock, which is approximately 15 milliseconds on Windows systems.
Available since 8
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Available since 8.1