Example

using System;
using System.Threading;

namespace Samples
{
  public class DuplicateWaitObjectExceptionSample
  {
    public static AutoResetEvent[] autoResetEvents =
                                      new AutoResetEvent[2];
    public static void Main()
    {
      try
      {
        autoResetEvents[0] = new AutoResetEvent(false);
        autoResetEvents[1] = autoResetEvents[0];
        WaitHandle.WaitAll(autoResetEvents);
      }
      catch(DuplicateWaitObjectException e)
      {
        Console.WriteLine("Exception: {0}", e);
      }
    }
  }
}
The output is
 Exception: System.DuplicateWaitObjectException: Duplicate objects in argument. at System.Threading.WaitHandle.WaitMultiple(WaitHandle[] waitHandles, Int32 millisecondsTimeout, Boolean exitContext, Boolean WaitAll) at System.Threading.WaitHandle.WaitAll(WaitHandle[] waitHandles, Int32 millisecondsTimeout, ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.