问题描述
我移植 C ++ API
code到 .NET
,展望函数调用 WaitHandle.WaitAny
来替代 WaitForMultipleObjects的
但 .NET4
我可以看到,这个函数挂钩到
I am porting C++ API
code to .NET
and looking into function call WaitHandle.WaitAny
as a replacement for WaitForMultipleObjects
but when debugging with .NET4
i can see that this function is hooked into
private static extern int WaitMultiple(
WaitHandle[] waitableSafeHandle,
int msTimeOut,
bool exitContext,
bool WaitAll);
这让我觉得,这个功能是不是sutable的端口。任何其他建议?
and this makes me think that this function is not sutable for the port. Any other suggestions?
推荐答案
这是事实, WaitHandle.WaitAny()
不是很够,以匹配 WaitForMultipleObjects的()。但是,你只需要使用 WaitHandle.WaitAll的()
和
It is true that WaitHandle.WaitAny()
is not quite enough to match the functionality of WaitForMultipleObjects()
. But you just need to use WaitHandle.WaitAll()
as well.
-
WaitHandle.WaitAny()
匹配WaitForMultipleObjects的()
调用,使用为WaitAll
参数设置为FALSE
。 -
WaitHandle.WaitAll的()
与为WaitAll
匹配其设置为TRUE
。
WaitHandle.WaitAny()
matchesWaitForMultipleObjects()
called with theWaitAll
parameter set toFALSE
,.WaitHandle.WaitAll()
matches it withWaitAll
set toTRUE
.
这篇关于WaitHandle.WaitAny匹配WaitForMultipleObjects的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!