Can multiple callers to WaitHandle::WaitAll deadlock?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
Can two callers to WaitHandle::WaitAll reach a deadlock if their array's contain the same WaitHandles in different orders?

For example
Client One:
WaitHandle.WaitAll ( new WaitHandle[] { wh1, wh2, wh3 } )

Client Two:
WaitHandle.WaitAll ( new WaitHandle[] { wh3, wh2, wh1 } )

Can these two clients reach deadlock if Client One receives the signal for wh1 and Client Two receives a signal for wh1, or will WaitAll protect against this?

Thanks,
-Mike
 
The synchronization protects you from this, WaitAll won't acquire the locks
unless it can acquire all of them. The .Net documentation doesn't say
anything about this but the Win32 synchronization API is clear about how
this works and I doubt that WaitHandle.WaitAll is more than a
WaitForMultipleObjects wrapper. But that's not answering your question in
the subject (there the answer is yes, they can deadlock very easily, just
not from what you're worried about).

Jerry
 
Back
Top