static void OnCloseComplete(IAsyncResult result)
            {
                if (result.CompletedSynchronously)
                {
                    return;
                }

                CloseAsyncResult thisPtr   = (CloseAsyncResult)result.AsyncState;
                Exception        exception = null;

                try
                {
                    thisPtr.upgradeProvider.EndClose(result);
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    exception = e;
                }

                thisPtr.Complete(false, exception);
            }
            static void OnReleaseConnectionPoolScheduled(object state)
            {
                CloseAsyncResult thisPtr = (CloseAsyncResult)state;
                bool             completeSelf;
                Exception        completionException = null;

                try
                {
                    completeSelf = thisPtr.OnReleaseConnectionPoolScheduled();
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    completeSelf        = true;
                    completionException = e;
                }

                if (completeSelf)
                {
                    thisPtr.Complete(false, completionException);
                }
            }
示例#3
0
            static bool HandleEndHostClose(IAsyncResult result)
            {
                CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState;

                thisPtr.host.EndHostClose(result);
                return(thisPtr.CloseDurableInstanceManager());
            }
示例#4
0
            static void OnClosePollerComplete(IAsyncResult result)
            {
                if (result.CompletedSynchronously)
                {
                    return;
                }

                CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState;

                Exception completionException = null;
                bool      completeSelf        = false;

                try
                {
                    completeSelf = thisPtr.CompleteClosePoller(result);
                }
                catch (Exception e)
                {
                    completionException = e;
                    completeSelf        = true;
                }

                if (completeSelf)
                {
                    thisPtr.Complete(false, completionException);
                }
            }
示例#5
0
            static void OnCloseInputSession(IAsyncResult result)
            {
                if (result.CompletedSynchronously)
                {
                    return;
                }

                CloseAsyncResult thisPtr             = (CloseAsyncResult)result.AsyncState;
                bool             completeSelf        = false;
                Exception        completionException = null;

                try
                {
                    completeSelf = thisPtr.HandleCloseInputSession(result, false);
                }
#pragma warning suppress 56500 // [....], transferring exception to another thread
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    completeSelf        = true;
                    completionException = e;
                }

                if (completeSelf)
                {
                    thisPtr.Complete(false, completionException);
                }
            }
示例#6
0
            static void OnCloseComplete(IAsyncResult result)
            {
                if (result.CompletedSynchronously)
                {
                    return;
                }

                CloseAsyncResult thisPtr   = (CloseAsyncResult)result.AsyncState;
                Exception        exception = null;

                try
                {
                    thisPtr.communicationObject.EndClose(result);
                }
#pragma warning suppress 56500 // covered by FxCOP
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    exception = e;
                }

                thisPtr.Complete(false, exception);
            }
示例#7
0
            static bool OnCloseCompletion(IAsyncResult result)
            {
                CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState;

                thisPtr.communicationObject.OnEndClose(result);
                thisPtr.NotifyClosed();
                return(true);
            }
示例#8
0
        protected void CompleteClose(bool syncComplete, Exception exception)
        {
            CloseAsyncResult closeResult = Interlocked.Exchange(ref this.pendingClose, null);

            if (closeResult != null)
            {
                closeResult.Signal(syncComplete, exception);
            }
        }
示例#9
0
            static bool HandleDurableInstanceManagerEndClose(IAsyncResult result)
            {
                CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState;

                thisPtr.host.durableInstanceManager.EndClose(result);

                thisPtr.host.WorkflowServiceHostPerformanceCounters.Dispose();
                return(true);
            }
示例#10
0
            private static bool CompleteBaseClose(IAsyncResult result)
            {
                // AsyncResult.AsyncCompletionWrapperCallback takes care of catching exceptions for us.
                CloseAsyncResult <T> thisPtr = (CloseAsyncResult <T>)result.AsyncState;

                // We are completing the base class close operation at this point.
                thisPtr.baseEndClose(result);

                return(true);
            }
示例#11
0
 public void OnEndOuterListenerClose(IAsyncResult result)
 {
     if (result is CompletedAsyncResult)
     {
         CompletedAsyncResult.End(result);
     }
     else
     {
         CloseAsyncResult <TInnerChannel, TInnerItem> .End(result);
     }
 }
示例#12
0
 public void EndClose(IAsyncResult result)
 {
     if (result is AlreadyClosedAsyncResult)
     {
         CompletedAsyncResult.End(result);
     }
     else
     {
         CloseAsyncResult.End(result);
     }
 }
示例#13
0
            private static bool CompleteCloseOutputChannel(IAsyncResult result)
            {
                // AsyncResult.AsyncCompletionWrapperCallback takes care of catching exceptions for us.
                CloseAsyncResult <T> thisPtr = (CloseAsyncResult <T>)result.AsyncState;

                // We are completing the base class close operation at this point.
                thisPtr.channel.UdpOutputChannel.EndClose(result);

                thisPtr.channel.Cleanup(false, thisPtr.timeoutHelper.RemainingTime());

                return(thisPtr.BeginBaseClose());
            }
示例#14
0
 public void EndClose(IAsyncResult result)
 {
     if (result is CompletedAsyncResult)
     {
         CompletedAsyncResult.End(result);
     }
     else
     {
         AmqpTrace.Provider.AmqpLogOperationVerbose(this, TraceOperation.Execute, "EndClose");
         CloseAsyncResult.End(result);
     }
 }
示例#15
0
    public IAsyncResult DefaultOnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
    {
        // Modify the placeholder async result we already instantiated.
        CloseAsyncResult.Callback   = callback;
        CloseAsyncResult.AsyncState = state;

        // The mock always Completes the IAsyncResult before handing it back.
        // This is done because the sync path has no access to this IAsyncResult
        // that happens behind the scenes.
        CloseAsyncResult.Complete();

        return(CloseAsyncResult);
    }
            static bool OnInputSessionClosed(IAsyncResult result)
            {
                CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState;

                using (Message message = thisPtr.channel.receiveQueue.EndDequeue(result))
                {
                    if (message != null)
                    {
                        throw CreateReceiveShutdownReturnedNonNull(message);
                    }
                }
                thisPtr.channel.OnInputSessionClosed();
                return(true);
            }
示例#17
0
 protected override void OnEndClose(IAsyncResult result)
 {
     try
     {
         CloseAsyncResult.End(result);
         this.TraceBaseAddresses();
         ThreadTrace.StopTracing();
     }
     catch (TimeoutException exception)
     {
         if (DiagnosticUtility.ShouldTraceWarning)
         {
             TraceUtility.TraceEvent(TraceEventType.Warning, 0x8002e, System.ServiceModel.SR.GetString("TraceCodeServiceHostTimeoutOnClose"), this, exception);
         }
         base.Abort();
     }
 }
示例#18
0
            static void OnWaitForStopLater(object state)
            {
                CloseAsyncResult thisPtr = (CloseAsyncResult)state;

                Exception completionException = null;

                try
                {
                    thisPtr.CompleteWaitForStop();
                }
                catch (Exception e)
                {
                    completionException = e;
                }

                thisPtr.Complete(false, completionException);
            }
示例#19
0
 public void EndClose(IAsyncResult result)
 {
     try
     {
         if (result is CompletedAsyncResult)
         {
             CompletedAsyncResult.End(result);
         }
         else
         {
             CloseAsyncResult.End(result);
         }
     }
     finally
     {
         this.NotifyClosed();
     }
 }
            static bool OnOutputSessionClosed(IAsyncResult result)
            {
                CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState;

                thisPtr.channel.EndCloseOutputSession(result);
                if (thisPtr.channel.isInputSessionClosed)
                {
                    return(true);
                }
                else
                {
                    IAsyncResult closeInputSessionResult =
                        thisPtr.channel.receiveQueue.BeginDequeue(thisPtr.timeouthelper.RemainingTime(),
                                                                  thisPtr.PrepareAsyncCompletion(CloseInputSessionCallback), thisPtr);
                    if (!closeInputSessionResult.CompletedSynchronously)
                    {
                        return(false);
                    }
                    return(OnInputSessionClosed(closeInputSessionResult));
                }
            }
示例#21
0
            static void OnCompleteCloseScheduled(object state)
            {
                CloseAsyncResult thisPtr             = (CloseAsyncResult)state;
                Exception        completionException = null;

                try
                {
                    thisPtr.OnCompleteCloseScheduled();
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    completionException = e;
                }

                thisPtr.Complete(false, completionException);
            }
示例#22
0
            private static void OnCloseComplete(IAsyncResult result)
            {
                if (result.CompletedSynchronously)
                {
                    return;
                }

                CloseAsyncResult thisPtr   = (CloseAsyncResult)result.AsyncState;
                Exception        exception = null;

                try
                {
                    thisPtr._communicationObject.EndClose(result);
                }
                catch (Exception e)
                {
                    exception = e;
                }

                thisPtr.Complete(false, exception);
            }
示例#23
0
            static void OnCloseChannelComplete(IAsyncResult result)
            {
                if (result.CompletedSynchronously)
                {
                    return;
                }

                CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState;

                Exception completionException = null;

                try
                {
                    thisPtr.CompleteCloseChannel(result);
                }
                catch (Exception e)
                {
                    completionException = e;
                }

                thisPtr.Complete(false, completionException);
            }
示例#24
0
            private static void CompleteCleanup(object state, TimeoutException exception)
            {
                CloseAsyncResult thisPtr             = (CloseAsyncResult)state;
                Exception        completionException = null;

                if (exception != null)
                {
                    Fx.Assert(exception.GetType() == typeof(TimeoutException), "Exception on callback should always be TimeoutException");
                    throw FxTrace.Exception.AsError(new TimeoutException(SR.TimeoutOnOperation(thisPtr.timeoutHelper.OriginalTimeout)));
                }

                try
                {
                    lock (thisPtr.channel.ThisLock)
                    {
                        thisPtr.channel.retransmissionDoneWaitHandle = null;

                        // another thread could have called Abort while Close() was waiting for retransmission to complete.
                        if (!thisPtr.channel.cleanedUp)
                        {
                            // never aborting here
                            thisPtr.channel.CleanupAfterWait(false);
                        }
                    }
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    completionException = e;
                }

                thisPtr.Complete(false, completionException);
            }
        public IAsyncResult BeginClose(TimeSpan timeout, AsyncCallback callback, object state)
        {
            if (timeout < TimeSpan.Zero)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("timeout", System.ServiceModel.SR.GetString("SFxTimeoutOutOfRange0")));
            }
            using ((DiagnosticUtility.ShouldUseActivity && this.TraceOpenAndClose) ? this.CreateCloseActivity() : null)
            {
                CommunicationState state2;
                lock (this.ThisLock)
                {
                    state2 = this.state;
                    if (state2 != CommunicationState.Closed)
                    {
                        this.state = CommunicationState.Closing;
                    }
                    this.closeCalled = true;
                }
                switch (state2)
                {
                    case CommunicationState.Created:
                    case CommunicationState.Opening:
                    case CommunicationState.Faulted:
                        this.Abort();
                        if (state2 == CommunicationState.Faulted)
                        {
                            throw TraceUtility.ThrowHelperError(this.CreateFaultedException(), Guid.Empty, this);
                        }
                        return new AlreadyClosedAsyncResult(callback, state);

                    case CommunicationState.Opened:
                    {
                        bool flag = true;
                        try
                        {
                            this.OnClosing();
                            if (!this.onClosingCalled)
                            {
                                throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnClosing"), Guid.Empty, this);
                            }
                            IAsyncResult result = new CloseAsyncResult(this, timeout, callback, state);
                            flag = false;
                            return result;
                        }
                        finally
                        {
                            if (flag)
                            {
                                if (DiagnosticUtility.ShouldTraceWarning)
                                {
                                    TraceUtility.TraceEvent(TraceEventType.Warning, 0x80004, System.ServiceModel.SR.GetString("TraceCodeCommunicationObjectCloseFailed", new object[] { this.GetCommunicationObjectType().ToString() }), this);
                                }
                                this.Abort();
                            }
                        }
                        break;
                    }
                    case CommunicationState.Closing:
                    case CommunicationState.Closed:
                        break;

                    default:
                        throw Fx.AssertAndThrow("CommunicationObject.BeginClose: Unknown CommunicationState");
                }
                return new AlreadyClosedAsyncResult(callback, state);
            }
        }
示例#26
0
 protected virtual void OnClose(TimeSpan timeout)
 {
     CloseAsyncResult.End(new CloseAsyncResult(this, timeout, null, null));
 }
            static void OnWaitCompleted(object state, TimeoutException asyncException)
            {
                CloseAsyncResult thisPtr = (CloseAsyncResult)state;

                thisPtr.Complete(false, asyncException);
            }
 public void EndClose(IAsyncResult result)
 {
     CloseAsyncResult.End(result);
 }
示例#29
0
 protected override void OnEndClose(IAsyncResult result)
 {
     CloseAsyncResult <TChannel> .End(result);
 }
示例#30
0
 protected override void OnEndClose(IAsyncResult result)
 {
     CloseAsyncResult <QueueItemType> .End(result);
 }
        public IAsyncResult BeginClose(TimeSpan timeout, AsyncCallback callback, object state)
        {
            if (timeout < TimeSpan.Zero)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                    new ArgumentOutOfRangeException("timeout", SR.GetString(SR.SFxTimeoutOutOfRange0)));

            using (DiagnosticUtility.ShouldUseActivity && this.TraceOpenAndClose ? this.CreateCloseActivity() : null)
            {
                CommunicationState originalState;
                lock (ThisLock)
                {
                    originalState = this.state;
#if DEBUG
                    if (closeStack == null)
                        closeStack = new StackTrace();
#endif
                    if (originalState != CommunicationState.Closed)
                        this.state = CommunicationState.Closing;

                    this.closeCalled = true;
                }

                switch (originalState)
                {
                    case CommunicationState.Created:
                    case CommunicationState.Opening:
                    case CommunicationState.Faulted:
                        this.Abort();
                        if (originalState == CommunicationState.Faulted)
                        {
                            throw TraceUtility.ThrowHelperError(this.CreateFaultedException(), Guid.Empty, this);
                        }
                        return new AlreadyClosedAsyncResult(callback, state);

                    case CommunicationState.Opened:
                        {
                            bool throwing = true;
                            try
                            {
                                OnClosing();
                                if (!this.onClosingCalled)
                                    throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnClosing"), Guid.Empty, this);

                                IAsyncResult result = new CloseAsyncResult(this, timeout, callback, state);
                                throwing = false;
                                return result;
                            }
                            finally
                            {
                                if (throwing)
                                {
                                    if (DiagnosticUtility.ShouldTraceWarning)
                                    {
                                        TraceUtility.TraceEvent(TraceEventType.Warning, TraceCode.CommunicationObjectCloseFailed, SR.GetString(SR.TraceCodeCommunicationObjectCloseFailed, this.GetCommunicationObjectType().ToString()), this);
                                    }

                                    Abort();
                                }
                            }
                        }

                    case CommunicationState.Closing:
                    case CommunicationState.Closed:
                        return new AlreadyClosedAsyncResult(callback, state);

                    default:
                        throw Fx.AssertAndThrow("CommunicationObject.BeginClose: Unknown CommunicationState");
                }
            }
        }
示例#32
0
        public IAsyncResult BeginClose(TimeSpan timeout, AsyncCallback callback, object state)
        {
            if (timeout < TimeSpan.Zero)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("timeout", System.ServiceModel.SR.GetString("SFxTimeoutOutOfRange0")));
            }
            using ((DiagnosticUtility.ShouldUseActivity && this.TraceOpenAndClose) ? this.CreateCloseActivity() : null)
            {
                CommunicationState state2;
                lock (this.ThisLock)
                {
                    state2 = this.state;
                    if (state2 != CommunicationState.Closed)
                    {
                        this.state = CommunicationState.Closing;
                    }
                    this.closeCalled = true;
                }
                switch (state2)
                {
                case CommunicationState.Created:
                case CommunicationState.Opening:
                case CommunicationState.Faulted:
                    this.Abort();
                    if (state2 == CommunicationState.Faulted)
                    {
                        throw TraceUtility.ThrowHelperError(this.CreateFaultedException(), Guid.Empty, this);
                    }
                    return(new AlreadyClosedAsyncResult(callback, state));

                case CommunicationState.Opened:
                {
                    bool flag = true;
                    try
                    {
                        this.OnClosing();
                        if (!this.onClosingCalled)
                        {
                            throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnClosing"), Guid.Empty, this);
                        }
                        IAsyncResult result = new CloseAsyncResult(this, timeout, callback, state);
                        flag = false;
                        return(result);
                    }
                    finally
                    {
                        if (flag)
                        {
                            if (DiagnosticUtility.ShouldTraceWarning)
                            {
                                TraceUtility.TraceEvent(TraceEventType.Warning, 0x80004, System.ServiceModel.SR.GetString("TraceCodeCommunicationObjectCloseFailed", new object[] { this.GetCommunicationObjectType().ToString() }), this);
                            }
                            this.Abort();
                        }
                    }
                    break;
                }

                case CommunicationState.Closing:
                case CommunicationState.Closed:
                    break;

                default:
                    throw Fx.AssertAndThrow("CommunicationObject.BeginClose: Unknown CommunicationState");
                }
                return(new AlreadyClosedAsyncResult(callback, state));
            }
        }