Exemplo n.º 1
0
        static void OnEnteredAsync(object state, TimeoutException exception)
        {
            EnterAsyncData         data    = (EnterAsyncData)state;
            ThreadNeutralSemaphore thisPtr = data.Semaphore;
            Exception exceptionToPropagate = exception;

            if (exception != null)
            {
                if (!thisPtr.RemoveWaiter(data.Waiter))
                {
                    // The timeout raced with Exit and exit won.
                    // We've successfully entered.
                    exceptionToPropagate = null;
                }
            }

            Fx.Assert(!thisPtr.waiters.Contains(data.Waiter), "The waiter should have been removed already.");

            if (thisPtr.aborted)
            {
                exceptionToPropagate = thisPtr.CreateObjectAbortedException();
            }

            data.Callback(data.State, exceptionToPropagate);
        }
        private static void OnEnteredAsync(object state, TimeoutException exception)
        {
            EnterAsyncData         data      = (EnterAsyncData)state;
            ThreadNeutralSemaphore semaphore = data.Semaphore;
            Exception asyncException         = exception;

            if ((exception != null) && !semaphore.RemoveWaiter(data.Waiter))
            {
                asyncException = null;
            }
            if (semaphore.aborted)
            {
                asyncException = semaphore.CreateObjectAbortedException();
            }
            data.Callback(data.State, asyncException);
        }