/// <summary>
        ///
        /// </summary>
        /// <param name="waitHandles"></param>
        /// <param name="millisecondsTimeout"></param>
        /// <returns></returns>
        public static int WaitAny(EventWaitHandleEx[] waitHandles, int millisecondsTimeout)
        {
            if (waitHandles == null)
            {
                throw new ArgumentNullException("waitHandles");
            }

            var handles = new IntPtr[waitHandles.Length];
            for (var i = 0; i < handles.Length; i++)
            {
                handles[i] = waitHandles[i].Handle;
            }

            return NativeMethods.WaitForMultipleObjects(handles.Length, handles, false, millisecondsTimeout);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="waitHandles"></param>
 /// <returns></returns>
 public static int WaitAny(EventWaitHandleEx[] waitHandles)
 {
     return WaitAny(waitHandles, Timeout.Infinite);
 }