Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WaitHandle.WaitAny to match WaitForMultipleObjects functionality

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);

and this makes me think that this function is not sutable for the port. Any other suggestions?

like image 974
user234567 Avatar asked Sep 15 '11 12:09

user234567


1 Answers

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() matches WaitForMultipleObjects() called with the WaitAll parameter set to FALSE,.
  • WaitHandle.WaitAll() matches it with WaitAll set to TRUE.
like image 83
David Heffernan Avatar answered Oct 11 '22 20:10

David Heffernan