how can i use a time delay in a loop after certain rotation? Suppose:
for(int i = 0 ; i<64;i++)
{
........
}
i want 1 sec delay after ea
Once I needed to write a program witch was so sensitive and needed accurate timing (about Nano seconds).
I used all sorts of stuff like Thread.Sleep()
, Timer and... but none of them was that accurate that could answer my needs so I used this code for delaying:
var stopWatch = new Stopwatch();
for(int i = 0 ; i<64;i++)
{
stopWatch.Restart();
while (stopWatch.ElapsedMilliseconds <= 1000)
{
}
}
Of course this way is not very CPU friendly, yet when you need accuracy that much you have to go old school.