System.Threading.WaitHandle.WaitMultiple C# (CSharp) Method

WaitMultiple() private method

private WaitMultiple ( WaitHandle waitHandles, int millisecondsTimeout, bool exitContext, bool WaitAll ) : int
waitHandles WaitHandle
millisecondsTimeout int
exitContext bool
WaitAll bool
return int
        private static extern int WaitMultiple(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext, bool WaitAll);

Usage Example

Beispiel #1
0
        public static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
        {
            if (waitHandles == null)
            {
                throw new ArgumentNullException(Environment.GetResourceString("ArgumentNull_Waithandles"));
            }
            if (waitHandles.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyWaithandleArray"));
            }
            if (64 < waitHandles.Length)
            {
                throw new NotSupportedException(Environment.GetResourceString("NotSupported_MaxWaitHandles"));
            }
            if (-1 > millisecondsTimeout)
            {
                throw new ArgumentOutOfRangeException("millisecondsTimeout", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1"));
            }
            WaitHandle[] waitHandles1 = new WaitHandle[waitHandles.Length];
            for (int index = 0; index < waitHandles.Length; ++index)
            {
                WaitHandle waitHandle = waitHandles[index];
                if (waitHandle == null)
                {
                    throw new ArgumentNullException(Environment.GetResourceString("ArgumentNull_ArrayElement"));
                }
                if (RemotingServices.IsTransparentProxy((object)waitHandle))
                {
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_WaitOnTransparentProxy"));
                }
                waitHandles1[index] = waitHandle;
            }
            int num = WaitHandle.WaitMultiple(waitHandles1, millisecondsTimeout, exitContext, false);

            if (AppDomainPauseManager.IsPaused)
            {
                AppDomainPauseManager.ResumeEvent.WaitOneWithoutFAS();
            }
            if (128 <= num && 128 + waitHandles1.Length > num)
            {
                int location = num - 128;
                if (0 <= location && location < waitHandles1.Length)
                {
                    WaitHandle.ThrowAbandonedMutexException(location, waitHandles1[location]);
                }
                else
                {
                    WaitHandle.ThrowAbandonedMutexException();
                }
            }
            GC.KeepAlive((object)waitHandles1);
            return(num);
        }