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

Re: Can multiple callers to WaitHandle::WaitAll deadlock? by Jerry

Jerry
Thu Jun 10 19:28:21 CDT 2004

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

"Michael Wohltman" <Michael Wohltman@discussions.microsoft.com> wrote in
message news:C6938CFB-1876-49D6-A5C1-60CA5CD3E7E5@microsoft.com...
> 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