Waitable Timers as alternative to sleep.
Hello,
My execution of the following waitable timer code did not achieve the results expected. There seems to be no
pause at all when invoked, no matter what the input is for MillisSeconds. The code used is as follows:
#define STRICT 1#define WIN32_LEAN_AND_MEAN#define _WIN32_WINDOWS 0x0500 // Not supported by 95#include <windows.h>DWORD Wait(DWORD MilliSeconds) {DWORD dw;HANDLE hTimer;LARGE_INTEGER DueTime;LONGLONG MilliSecond=-10000;if (_winmajor == 1 && _winminor <= 4)// Win95 or less?return WAIT_FAILED;// This is not best since WAIT_FAILED implies// that GetLastError will say what the problem isDueTime.QuadPart = MilliSeconds * MilliSecond;hTimer = CreateWaitableTimer(NULL, TRUE, NULL);if (!SetWaitableTimer(hTimer, &DueTime, 0, NULL, NULL, FALSE)) {CloseHandle(hTimer);return WAIT_FAILED; // This needs to be improved// A more meaningful return value should be retuned; A BOOL// return value would be good and upon failure the caller could// call GetLastError}dw = WaitForSingleObject(hTimer, 10000);// A maximum of 10 seconds?// Adjust if necessaryCloseHandle(hTimer);return dw;}Thanks in advance.

