CoWaitForMultipleHandles and WaitForSingleObjectExdont work for me
-
14 มีนาคม 2555 0:42
I have created a thread which does polling to a service at regular intervals. To introduce the delay between successive polls, I am trying to use the above methods.
HANDLE m_event;
DWORD dwsignalled;
// Create an event that will never happen.
m_event= CreateEventEx(0, FALSE, FALSE, 0);CoWaitForMultipleHandles(COWAIT_WAITALL, 60*1000, 1, &m_event, &dwsignalled);
But this does not seem to block the thread.
I also tried DWORD wait = WaitForSingleObjectEx(m_event, MAX_WAIT_DELAY_MS, false);
That does not work either.
- แก้ไขโดย amshinde 14 มีนาคม 2555 0:42
ตอบทั้งหมด
-
15 มีนาคม 2555 22:11ผู้ดูแล
Have you considered the ThreadPoolTimer::CreateTimer to accomplish this polling? The Thread pool sample demonstrates the use.
Try this to get the WaitForSingleObjectEx call to work as desired:
HANDLE m_event; m_event= CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS); WaitForSingleObjectEx(m_event, 60000, false);
Thanks!
David Lamb
- เสนอเป็นคำตอบโดย DavidLambMicrosoft, Moderator 16 มีนาคม 2555 0:28
- ทำเครื่องหมายเป็นคำตอบโดย amshinde 20 มีนาคม 2555 21:38
-
16 มีนาคม 2555 0:12Ya. I did go with the the CreateTimer function. Thanks!