Reputation: 51997
I'd like to add a delay between 2 lines of code because I'm testing an updateprogress template. Ideally, the one-liner.
Thanks.
Upvotes: 3
Views: 2922
Reputation: 16142
System.Threading.Thread.Sleep(int time_ms); //One line, no 'using' :)
Upvotes: 0
Reputation: 85106
Try the Sleep method. Example:
Thread.Sleep(3000); //3 seconds
You will need to add this using directive:
using System.Threading;
to get access to the method.
The parameter you pass it is the number of milliseconds you want to suspend the current thread.
Upvotes: 9
Reputation: 834
You could put that line in a condition, that will only be 'true', passing that amount of time, using the delay method: Thread.Sleep(time)
Upvotes: 0
Reputation: 47164
You're looking for the Thread.Sleep method and Preprocessor Directives:
#if DEBUG
Thread.Sleep(1000);
#endif
Upvotes: 1
Reputation: 108830
You might want to use Thread.Sleep
. It takes the time to sleep in milliseconds
Thread.Sleep(10000);//Waits 10 seconds.
Upvotes: 0