William Stacey [C# MVP] wrote:
> This can get slightly more involved and depends on the handle type. If the
> wait events are ManualResetEvents, then a timeout may not matter to your
> code as they stay signaled anyway. AutoResetEvents are more an issue as
> some may be reset by the WaitOne() call before the timeout and that could
> get messy - but can still be workable depending on needs. Semaphores,
> however, do change their state even with the win32 waitformultipleobjects as
> it waits for each one in turn (so the net effect would be the same as using
> the shown implementation). If one understands the potential issues and
> takes care, the pattern can prove useful when waiting on many handles.
>
> --
> William Stacey [C# MVP]
>
> "Peter Ritchie [C# MVP]" <PRSoCo@newsgroups.nospam> wrote in message
> news:DA246A3B-4746-47EF-96A6-A082865DAC71@microsoft.com...
> | My calling WaitOne in a loop like that you're allowing the thread to gain
> | ownership of a WaitHandle without having ownership of all WaitHandles.
> | WaitAll does not give ownership of all WaitHandes until all WaitHandles
> have
> | entered a signaled state.
> |
> | WaitAll can be given a timeout, if that timeout expires before all
> | WaitHandles are signaled the thread never gains ownership of any of the
> | WaitHandles even if some of them have signaled.
> |
> | BTW, you'd have this same problem if had to split up more thane 64
> | WaitHandles across multiple threads with multiple calls to WaitAll...
> |
> | --
> | Browse
http://connect.microsoft.com/VisualStudio/feedback/ and vote.
> |
http://www.peterRitchie.com/blog/ > | Microsoft MVP, Visual Developer - Visual C#
> |
> |
> | "William Stacey [C# MVP]" wrote:
> |
> | > How so?
> | >
> | > --
> | > William Stacey [C# MVP]
> | >
> | > "Ben Voigt" <rbv@nospam.nospam> wrote in message
> | > news:Os7SKySKHHA.3936@TK2MSFTNGP02.phx.gbl...
> | > |
> | > | "William Stacey [C# MVP]" <william.stacey@gmail.com> wrote in message
> | > | news:ulAX0G9JHHA.3872@TK2MSFTNGP06.phx.gbl...
> | > | > Fortunately, WaitAll is easy to implement with any number of
> handles.
> | > | > Here
> | > | > is a simple example.
> | > |
> | > | Which does not replicate the proper semantics and therefore is
> vulnerable
> | > to
> | > | deadlock.
> | >
> | >
> | >