本文介绍了WaitHandle.WaitAny匹配WaitForMultipleObjects的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我移植 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() matches WaitForMultipleObjects() called with the WaitAll parameter set to FALSE,.
  • WaitHandle.WaitAll() matches it with WaitAll set to TRUE.

这篇关于WaitHandle.WaitAny匹配WaitForMultipleObjects的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 15:31