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?
Look into TimeSetEvent() and the other multimedia timer functions.
Both sleep and TimeSetEvent have an interval in MILLIseconds, but I need to wait some MICROseconds (1E-6 sec)...
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.