小编Chr*_*ris的帖子

当多个句柄同时发出信号时,WaitForMultipleObjects的行为

给定:我用自动重置事件填充一个句柄数组,并将其传递给具有bWaitAll = FALSE的WaitForMultipleObjects.

从MSDN:"当bWaitAll为FALSE时,此函数按顺序检查数组中的句柄,从索引0开始,直到其中一个对象发出信号.如果多个对象变为信号,则该函数返回其对象被发信号通知的数组中第一个句柄的索引."

所以,现在如果多个对象发出信号,我将获得第一个的索引.我是否必须通过我的阵列循环以查看是否有其他人发出信号?

现在我有一个循环:

For ( ; ; )
{
WaitForMultipleObjects(…)
If  (not failed)
     Process object that called. 
     Remove the handle that signaled from the array.
     Compact the arrary.
}
Run Code Online (Sandbox Code Playgroud)

events winapi multithreading

5
推荐指数
2
解决办法
8969
查看次数

标签 统计

events ×1

multithreading ×1

winapi ×1