Method Sleep
Sleep(TimeSpan)
Suspends the execution of the current method for a specified duration.
Declaration
void Sleep(TimeSpan delay)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | delay | The amount of time for which to suspend execution. |
Remarks
This method synchronously delays the execution of the current method for the specified delay
.
It utilizes a bunch of different methods (Thread.Sleep, Task.Delay and few other) to implement the delay in the most accurate way possible,
and it will block the calling thread until the delay has elapsed or the operation is canceled.
Exceptions
Type | Condition |
---|---|
OperationCanceledException | Thrown if the operation is canceled through the CancellationToken. |
Sleep(int)
Suspends the execution of the current method for a specified duration.
Declaration
void Sleep(int delayMs)
Parameters
Type | Name | Description |
---|---|---|
int | delayMs | The amount of time in milliseconds for which to suspend execution. |
Remarks
This method synchronously delays the execution of the current method for the specified delay
.
It utilizes a bunch of different methods (Thread.Sleep, Task.Delay and few other) to implement the delay in the most accurate way possible,
and it will block the calling thread until the delay has elapsed or the operation is canceled.
Exceptions
Type | Condition |
---|---|
OperationCanceledException | Thrown if the operation is canceled through the CancellationToken. |
Sleep(double)
Suspends the execution of the current method for a specified duration.
Declaration
void Sleep(double delayMs)
Parameters
Type | Name | Description |
---|---|---|
double | delayMs | The amount of time in milliseconds for which to suspend execution. |
Remarks
This method synchronously delays the execution of the current method for the specified delay
.
It utilizes a bunch of different methods (Thread.Sleep, Task.Delay and few other) to implement the delay in the most accurate way possible,
and it will block the calling thread until the delay has elapsed or the operation is canceled.
Exceptions
Type | Condition |
---|---|
OperationCanceledException | Thrown if the operation is canceled through the CancellationToken. |