Let's say I have created 5 timers in my program with CreateWaitableTimer (auto reset) and then use WaitForMultipleObjects to wait until at least one of them is signaled. How can I then determine which of the timers are signaled. The first one I may get by using the returncode of WaitForMultipleObjects, but what if more that one is signaled?

Posted on 2005-10-13 11:49:01 by japheth
Maybe you can call RegisterWaitForSingleObject on each timer object, and use callbacks? It's just a guess, I've never used that function.
Posted on 2005-10-13 16:03:41 by QvasiModo
I'm assuming you used FALSE for bWaitAll.

If the function succeeds the return value will be the index in the lpHandles array of the object that satisfied the wait.

If the funciton fails it will be out of range of the array.

Posted on 2005-10-13 16:14:33 by Sparafusile
The problem is to determine all objects that satisfied the wait, of course when bWaitAll is FALSE. The return value from WaitForMultipleObjects will only give you the object with the lesser index.

From MSDN:

When bWaitAll is FALSE, this function checks the handles in the array in order starting with index 0, until one of the objects is signaled. If multiple objects become signaled, the function returns the index of the first handle in the array whose object was signaled.
Posted on 2005-10-13 16:18:57 by QvasiModo
I don't know if RegisterWaitForSingleObject would help, but it is implemented in win2k+ only, not on win98. So I cannot use it.

I will now call CreateWaitableTimer with bManualReset==TRUE and then reset the Timers manually with SetWaitableTimer
Posted on 2005-10-14 01:00:46 by japheth