There is Task.Delay in .NET 4.5
How can I do the same in .NET 4.0?
The delay() function is built upon a C library function called clock(). The clock() function returns a time value in clock ticks, which is based on the processor's speed. The value returned is of the clock_t variable type. You can use subsequent reads of the clock() function to determine elapsed time.
The function sleep gives a simple way to make the program wait for a short interval. If your program doesn't use signals (except to terminate), then you can expect sleep to wait reliably throughout the specified interval.
Insert, wherever you need your program to make a delay:sleep(1000); Change the "1000" to the number of milliseconds you want to wait (for example, if you want to make a 2 second delay, replace it with "2000".
The first method is simply using Loop program function in which Delay() function is made or by providing for(); delay loop in Embedded C programming. You can define your own value of delay and how long you want to display. For example- for(i=0;i<"any decimal value";i++); this is the delay for loop used in embedded C.
Use the Microsoft.Bcl.Async package from NuGet, it has TaskEx.Delay
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With