RSSArchive for April, 2012

Apr

25

Slowing down a loop in .NET

Posted by Leave a Comment

One way to slow down a loop in .NET is to use the System.Threading.Thread.Sleep() method. This will suspend the current thread for a specified amount of time. Note that this is not the same as a timer which fires on the specified interval. The Thread.Sleep method simply pauses that thread for a given amount of time before continuing.

It’s as simple as adding

//Pause current thread for one second before continuing
System.Threading.Thread.Sleep(1000);

to the loop you would like to slow down.
Continue Reading