Sunday, September 12, 2010

How to Sleep/Wait in a given Thread in C#



This is a simple piece of code that allows you to Pause between given lines of code in a thread. I had implemented this in my S-Cubed application (screenshot above) so that all the machines wouldn't have psexec run at once or immediately after one another.


The code is simply:
System.Threading.Thread.Sleep(Convert.ToInt32(nmrWait.Value) * 1000);

No comments:

Post a Comment