Implementing timing control in loop
Posted on 2000-03-25
I would like to iterate a loop, say once every few milliseconds. I tried using Sleep to do it. However, upon printing out the time using GetTickCount(), I notice that the timing interval is always rounded up to the next 10 milliseconds.
For example, if the code is something like the following.
for(i = 1; i <= 100; i++)
tickcount = GetTickCount();
The printed result would be something like:
and so on. That is, whether I put Sleep(21), Sleep(22) or whatever, the interval would never be accurate to the millisecond but would be rounded up to the next 10 milliseconds.
Is there any way to implement some timing control so that it is more accurate?