If your programming for windows, you can also use the SetTimer() function.
This is the prototype found in the MSDN library:
UINT_PTR SetTimer(
HWND hWnd, // handle to window
UINT_PTR nIDEvent, // timer identifier
UINT uElapse, // time-out value
TIMERPROC lpTimerFunc // timer procedure
);
It is declared in the Winuser.h (include windows.h) and you must provide your own callback function which will be called by windows when its time. The prototype of the callback is:
VOID CALLBACK TimerProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_TIMER message
UINT_PTR idEvent, // timer identifier
DWORD dwTime // current system time
);
Although the prototype implies you need to supply a handle to a window, this is not necessary and you can set it to NULL. The difference of timing this way is that your program will not be halted the way a function like Sleep() does, and your program can continue doing its tasks until it is interrupted by the timed out callback, after which your program can continue its tasks. (There is also the Beep() function, which does simply what its names says: it gives a beep. And I've use it to experiment with SetTimer(); it works nice and easy =)