Is it possible to make a thread wait for a user defined number of microseconds? It doesn't have to be accurate to 1us. I can use a loop with GetTickCount to wait for say 20ms but not for microseconds.. any ideas?
Posted on 2000-12-31 05:06:00 by Thomas
Sleep() ?
Posted on 2000-12-31 11:02:00 by BogdanOntanu
Look into TimeSetEvent() and the other multimedia timer functions.
Posted on 2000-12-31 12:27:00 by martin
Both sleep and TimeSetEvent have an interval in MILLIseconds, but I need to wait some MICROseconds (1E-6 sec)...
Posted on 2000-12-31 12:35:00 by Thomas
You can use QueryPerformanceCounter and QueryPerformanceFrequency to wait for very very short periods. Usually, the count in QueryPerformanceCounter is incremented 1,193,180 times per second (because the 8253 chip is fixed at 1.19318 MHz), so waiting for one or two increments will give you approximately 1 microsecond. However, be sure to check if the high performance timer chip is installed on a machine. It describes that in the Win32 API.
Posted on 2000-12-31 13:17:00 by Racso