当 bWaitAll 为 TRUE 时,WaitForMultipleObjects return 值
WaitForMultipleObjects return value when bWaitAll is TRUE
由于有些人对文档有不同的解释,我试图一劳永逸地澄清 WaitForMultipleObjects 的 return 值
bWaitAll = TRUE
.
- 所有 个句柄已发出信号
基于文档:
Return值
WAIT_OBJECT_0 到 (WAIT_OBJECT_0 + nCount– 1)
如果 bWaitAll 为 TRUE,则 return 值表示所有指定对象的状态都已发出信号。
问题
说我已经向这个函数传递了 5 个句柄,并且 所有 个句柄都收到了信号,return 值是 WAIT_OBJECT_0
吗?
备注
我正在尝试以编程方式验证 WaitForMultipleObjects
是否成功。
DWORD dwWaitForMultipleObjectsRes = WaitForMultipleObjects(dwOpenProcessCount, handles, TRUE, m_dwWaitTimeForProcToBeKilled);
if (dwWaitForMultipleObjectsRes != WAIT_OBJECT_0)
// failed?
我要验证条件是否正确。
documentation 很清楚 return 代码从 WAIT_OBJECT_0 到 WAIT_OBJECT_0 + nCount - 1 将 returned 如果等待满足:
If bWaitAll is TRUE, the return value indicates that the state of all
specified objects is signaled.
它没有指定确切的值,所以除了在那个范围.
之外,没有人能确定它会是什么
因此,与其测试 if (dwWaitForMultipleObjectsRes == WAIT_OBJECT_0)
,不如测试:
if ((dwWaitForMultipleObjectsRes >= WAIT_OBJECT_0)
&& (dwWaitForMultipleObjectsRes < (WAIT_OBJECT_0 + dwOpenProcessCount)))
{
// wait satisfied, all objects signalled
}
由于有些人对文档有不同的解释,我试图一劳永逸地澄清 WaitForMultipleObjects 的 return 值
bWaitAll = TRUE
.- 所有 个句柄已发出信号
基于文档:
Return值
WAIT_OBJECT_0 到 (WAIT_OBJECT_0 + nCount– 1)
如果 bWaitAll 为 TRUE,则 return 值表示所有指定对象的状态都已发出信号。
问题
说我已经向这个函数传递了 5 个句柄,并且 所有 个句柄都收到了信号,return 值是 WAIT_OBJECT_0
吗?
备注
我正在尝试以编程方式验证 WaitForMultipleObjects
是否成功。
DWORD dwWaitForMultipleObjectsRes = WaitForMultipleObjects(dwOpenProcessCount, handles, TRUE, m_dwWaitTimeForProcToBeKilled);
if (dwWaitForMultipleObjectsRes != WAIT_OBJECT_0)
// failed?
我要验证条件是否正确。
documentation 很清楚 return 代码从 WAIT_OBJECT_0 到 WAIT_OBJECT_0 + nCount - 1 将 returned 如果等待满足:
If bWaitAll is TRUE, the return value indicates that the state of all specified objects is signaled.
它没有指定确切的值,所以除了在那个范围.
之外,没有人能确定它会是什么因此,与其测试 if (dwWaitForMultipleObjectsRes == WAIT_OBJECT_0)
,不如测试:
if ((dwWaitForMultipleObjectsRes >= WAIT_OBJECT_0)
&& (dwWaitForMultipleObjectsRes < (WAIT_OBJECT_0 + dwOpenProcessCount)))
{
// wait satisfied, all objects signalled
}