Can multiple callers to WaitHandle::WaitAll deadlock?

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
 
J

Jerry Pisk

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top