예제 #1
0
        /*========================================================================
        ** Waits for signal from all the objects.
        ** timeout indicates how long to wait before the method returns.
        ** This method will return either when all the object have been pulsed
        ** or timeout milliseonds have elapsed.
        ** ========================================================================*/
        private static int WaitMultiple(
            RuntimeThread currentThread,
            SafeWaitHandle[] safeWaitHandles,
            int count,
            int millisecondsTimeout,
            bool waitAll)
        {
            Debug.Assert(currentThread == RuntimeThread.CurrentThread);
            Debug.Assert(safeWaitHandles != null);
            Debug.Assert(safeWaitHandles.Length >= count);

            IntPtr[] handles = currentThread.GetWaitedHandleArray(count);
            for (int i = 0; i < count; i++)
            {
                handles[i] = safeWaitHandles[i].DangerousGetHandle();
            }

            return(WaitForMultipleObjects(handles, count, waitAll, millisecondsTimeout));
        }