HANDLE hTimer = CreateWaitableTimer(NULL,FALSE,NULL);
2. Set
LARGE_INTEGER liDueTime;
const int nTimerUnitsPerSecond=10*1000*1000; // the unit of timer is 100 nano seconds
// Set the event the first time 2 seconds after calling SetWaitableTimer
liDueTime.QuadPart= -(STARTTIMERAFTERSECOND * m_nTimerUnitsPerSecond );
int nTimerInterVal = 10;
SetWaitableTimer(hTimer,&liDueTime, (nTimerInterVal*nTimerUnitsPerSecond), NULL, NULL, false);
3. Use
// Wait for the timer.
if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0)
printf("WaitForSingleObject failed (%d)\n", GetLastError());
else printf("Timer was signaled.\n");
沒有留言:
張貼留言