Behavior of WaitForMultipleObjects when multiple handles signal at the same time

后端 未结 4 950
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-13 09:24

Given: I fill up an array of handles with auto reset events and pass it off to WaitForMultipleObjects with bWaitAll = FALSE.

From MSDN: “When bWaitAll is FALSE, th

4条回答
  •  伪装坚强ぢ
    2021-01-13 09:39

    One other option you might have is to use RegisterWaitForSingleObject. The idea is that you flag the signaled state of event in a secondary array from the callback function and then signal a master event which is used to wake up your primary thread (which calls WaitForSingleObject on the master event).

    Obviously you'd have to take care to ensure that the secondary array was protected from access by the main thread but it would work.

提交回复
热议问题