Ejemplo 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);
        }
Ejemplo n.º 3
0
        private static void OnEnteredAsync(object state, TimeoutException exception)
        {
            ThreadNeutralSemaphore.EnterAsyncData enterAsyncDatum = (ThreadNeutralSemaphore.EnterAsyncData)state;
            ThreadNeutralSemaphore semaphore = enterAsyncDatum.Semaphore;
            Exception exception1             = exception;

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