Wait until multiple of 1/2 second

I'd like either (1) have a thread activate every 1/2 second, or (2) have a thread wait until the next multiple of 1/2 second before issuing a command to poll a device. (I already have the .h and .lib file to poll the device.)

Compilation is on Windows 7, C++200X.
Target machine is Windows Embedded Standard.

In the second mode, the pseudo-code would be:
while(1) {
... wait until next 1/2 second
Issue command to device
... wait until interrupt
read data from device
Last edited on
There are several ways to wait for an amount of time:

a) Sleep(500) may not be quite accurate on non-realtime system

b) Multimedia timer: timeSetEvent

c) Window timer: SetTimer

d) polling the high-resolution performance counter: QueryPerformanceCounter

Topic archived. No new replies allowed.