public void EndOpen(IAsyncResult result)
 {
     if (result is RefcountedCommunicationObject.AlreadyOpeningAsyncResult)
     {
         RefcountedCommunicationObject.AlreadyOpeningAsyncResult.End(result);
         return;
     }
     if (result is RefcountedCommunicationObject.SkippingOperationAsyncResult)
     {
         CompletedAsyncResult.End(result);
         return;
     }
     RefcountedCommunicationObject.OpenAsyncResult.End(result);
 }
 public void EndClose(IAsyncResult result)
 {
     if (result is RefcountedCommunicationObject.AlreadyClosedAsyncResult)
     {
         CompletedAsyncResult.End(result);
         return;
     }
     if (result is RefcountedCommunicationObject.SkippingOperationAsyncResult)
     {
         CompletedAsyncResult.End(result);
         return;
     }
     RefcountedCommunicationObject.CloseAsyncResult.End(result);
 }
        internal bool EndTryAccept(IAsyncResult result, out IChannelBinder channelBinder)
        {
            ErrorHandlingCompletedAsyncResult result2 = result as ErrorHandlingCompletedAsyncResult;

            if (result2 != null)
            {
                channelBinder = null;
                return(CompletedAsyncResult <bool> .End(result2));
            }
            try
            {
                channelBinder = this.binder.EndAccept(result);
                if (channelBinder != null)
                {
                    this.dispatcher.PendingChannels.Add(channelBinder.Channel);
                }
                return(true);
            }
            catch (CommunicationObjectAbortedException)
            {
                channelBinder = null;
                return(true);
            }
            catch (CommunicationObjectFaultedException)
            {
                channelBinder = null;
                return(true);
            }
            catch (TimeoutException)
            {
                channelBinder = null;
                return(false);
            }
            catch (CommunicationException exception)
            {
                this.HandleError(exception);
                channelBinder = null;
                return(false);
            }
            catch (Exception exception2)
            {
                if (Fx.IsFatal(exception2))
                {
                    throw;
                }
                this.HandleErrorOrAbort(exception2);
                channelBinder = null;
                return(false);
            }
        }
Esempio n. 4
0
 public void EndProcessRequest(IAsyncResult result)
 {
     using (_tracer.Step("LogStreamHandler.EndProcessRequest"))
     {
         if (result is CompletedAsyncResult)
         {
             CompletedAsyncResult.End(result);
         }
         else
         {
             _manager.EndProcessRequest(result);
         }
     }
 }
        public bool EndWaitForRequest(IAsyncResult result)
        {
            WaitForRequestAsyncResult waitForRequestResult = result as WaitForRequestAsyncResult;

            if (waitForRequestResult != null)
            {
                return(waitForRequestResult.End());
            }
            else
            {
                CompletedAsyncResult.End(result);
                return(true);
            }
        }
Esempio n. 6
0
        private static bool EndTryReceiveRequestContext(
            IAsyncResult result,
            out System.ServiceModel.Channels.RequestContext requestContext
            )
        {
            Contract.Assert(result != null);

            CompletedAsyncResult <bool> handlerResult = result as CompletedAsyncResult <bool>;

            if (handlerResult != null)
            {
                requestContext = null;
                return(CompletedAsyncResult <bool> .End(handlerResult));
            }
            else
            {
                try
                {
                    ChannelContext channelContext = (ChannelContext)result.AsyncState;
                    Contract.Assert(channelContext != null, "context cannot be null");
                    return(channelContext.Channel.EndTryReceiveRequest(result, out requestContext));
                }
                catch (CommunicationObjectAbortedException)
                {
                    requestContext = null;
                    return(true);
                }
                catch (CommunicationObjectFaultedException)
                {
                    requestContext = null;
                    return(true);
                }
                catch (CommunicationException)
                {
                    requestContext = null;
                    return(false);
                }
                catch (TimeoutException)
                {
                    requestContext = null;
                    return(false);
                }
                catch
                {
                    requestContext = null;
                    return(false);
                }
            }
        }
        public void EndBatchedOperation(IAsyncResult result)
        {
            if (result is BatchManager <TItem> .BatchedObjectsAsyncResult)
            {
                BatchManager <TItem> .BatchedObjectsAsyncResult.End(result);

                return;
            }
            if (result is CompletedAsyncResult)
            {
                CompletedAsyncResult.End(result);
                return;
            }
            this.BatchedEnd(result, Transaction.Current == null);
        }
        public override bool EndTryReceive(IAsyncResult result, out Message message)
        {
            if (result is CompletedAsyncResult <bool, Message> )
            {
                return(CompletedAsyncResult <bool, Message> .End(result, out message));
            }
            bool flag = base.EndTryReceive(result, out message);

            if ((flag && (message != null)) && this.receiveContextEnabled)
            {
                message.Properties[ReceiveContext.Name] = new MsmqSessionReceiveContext(this);
                Interlocked.Increment(ref this.incompleteMessageCount);
            }
            return(flag);
        }
Esempio n. 9
0
        public bool EndReceiveMessage(IAsyncResult result, out AmqpMessage message)
        {
            IEnumerable <AmqpMessage> amqpMessages;

            if (!(result is ReceivingAmqpLink.ReceiveAsyncResult))
            {
                message = CompletedAsyncResult <IEnumerable <AmqpMessage> > .End(result).FirstOrDefault <AmqpMessage>();

                return(true);
            }
            bool flag = ReceivingAmqpLink.ReceiveAsyncResult.End(result, out amqpMessages);

            message = amqpMessages.FirstOrDefault <AmqpMessage>();
            return(flag);
        }
        private static bool EndTryAcceptChannel(IAsyncResult result, out IReplyChannel channel)
        {
            Contract.Assert(result != null);

            CompletedAsyncResult <bool> handlerResult = result as CompletedAsyncResult <bool>;

            if (handlerResult != null)
            {
                channel = null;
                return(CompletedAsyncResult <bool> .End(handlerResult));
            }
            else
            {
                try
                {
                    HttpSelfHostServer server = (HttpSelfHostServer)result.AsyncState;
                    Contract.Assert(server != null);
                    Contract.Assert(server._listener != null);
                    channel = server._listener.EndAcceptChannel(result);
                    return(true);
                }
                catch (CommunicationObjectAbortedException)
                {
                    channel = null;
                    return(true);
                }
                catch (CommunicationObjectFaultedException)
                {
                    channel = null;
                    return(true);
                }
                catch (TimeoutException)
                {
                    channel = null;
                    return(false);
                }
                catch (CommunicationException)
                {
                    channel = null;
                    return(false);
                }
                catch
                {
                    channel = null;
                    return(false);
                }
            }
        }
Esempio n. 11
0
 protected override void OnEndOpen(IAsyncResult result)
 {
     if (this.listener != null)
     {
         try
         {
             this.listener.EndOpen(result);
             return;
         }
         catch (InvalidOperationException exception)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.CreateOuterExceptionWithEndpointsInformation(exception));
         }
     }
     CompletedAsyncResult.End(result);
 }
 public static void EndFloodEncodedMessage(IAsyncResult result)
 {
     if (result is CompletedAsyncResult)
     {
         CompletedAsyncResult.End(result);
     }
     else
     {
         FloodAsyncResult result3 = result as FloodAsyncResult;
         if (result3 == null)
         {
             throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("result", System.ServiceModel.SR.GetString("InvalidAsyncResult"));
         }
         result3.End();
     }
 }
 public void EndCloseInput(IAsyncResult result)
 {
     if (result is CloseCommunicationAsyncResult)
     {
         CloseCommunicationAsyncResult.End(result);
         if (Interlocked.Decrement(ref _activityWaiterCount) == 0)
         {
             _activityWaiter.Dispose();
             _activityWaiter = null;
         }
     }
     else
     {
         CompletedAsyncResult.End(result);
     }
 }
Esempio n. 14
0
 protected virtual void OnEndClose(IAsyncResult result)
 {
     if (result is CloseCommunicationAsyncResult)
     {
         CloseCommunicationAsyncResult.End(result);
         if (Interlocked.Decrement(ref _busyWaiterCount) == 0)
         {
             _busyWaiter.Dispose();
             _busyWaiter = null;
         }
     }
     else
     {
         CompletedAsyncResult.End(result);
     }
 }
Esempio n. 15
0
            protected override IEnumerator <Step> Steps()
            {
                for (int i = 0; i < this.iterationCount; ++i)
                {
                    yield return(Step.Await(
                                     false,
                                     (t, c, s) => new CompletedAsyncResult <bool>(t, c, s),
                                     (t, r) => CompletedAsyncResult <bool> .End(r)));

                    StackTrace stackTrace = new StackTrace(false);
                    if (stackTrace.FrameCount > 100)
                    {
                        throw new InvalidOperationException("Stack too deep!");
                    }
                }
            }
Esempio n. 16
0
        internal bool EndTryReceive(IAsyncResult result, out RequestContext requestContext)
        {
            ErrorHandlingCompletedAsyncResult result2 = result as ErrorHandlingCompletedAsyncResult;

            if (result2 != null)
            {
                requestContext = null;
                return(CompletedAsyncResult <bool> .End(result2));
            }
            try
            {
                return(this.binder.EndTryReceive(result, out requestContext));
            }
            catch (CommunicationObjectAbortedException)
            {
                requestContext = null;
                return(true);
            }
            catch (CommunicationObjectFaultedException)
            {
                requestContext = null;
                return(true);
            }
            catch (CommunicationException exception)
            {
                this.HandleError(exception);
                requestContext = null;
                return(false);
            }
            catch (TimeoutException exception2)
            {
                this.HandleError(exception2);
                requestContext = null;
                return(false);
            }
            catch (Exception exception3)
            {
                if (Fx.IsFatal(exception3))
                {
                    throw;
                }
                this.HandleErrorOrAbort(exception3);
                requestContext = null;
                return(false);
            }
        }
Esempio n. 17
0
 public void EndClose(IAsyncResult result)
 {
     try
     {
         if (result is CompletedAsyncResult)
         {
             CompletedAsyncResult.End(result);
         }
         else
         {
             CloseAsyncResult.End(result);
         }
     }
     finally
     {
         this.NotifyClosed();
     }
 }
Esempio n. 18
0
        public static void EndFloodEncodedMessage(IAsyncResult result)
        {
            CompletedAsyncResult cresult = result as CompletedAsyncResult;

            if (cresult != null)
            {
                CompletedAsyncResult.End(result);
            }
            else
            {
                FloodAsyncResult fresult = result as FloodAsyncResult;
                if (fresult == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("result", SR.GetString(SR.InvalidAsyncResult));
                }
                fresult.End();
            }
        }
Esempio n. 19
0
        protected override Stream OnEndGetState(IAsyncResult result)
        {
            if (!this.CachedState)
            {
                GetSessionStateResponseCommand body = AsyncResult <SbmpMessageSession.GetStateAsyncResult> .End(result).Response.GetBody <GetSessionStateResponseCommand>();

                this.CachedState = body.SessionState.Stream == null;
                return(body.SessionState.Stream);
            }
            CompletedAsyncResult.End(result);
            Stream stream = null;

            if (this.sessionState != null)
            {
                stream            = this.sessionState.Stream;
                this.sessionState = null;
                this.CachedState  = false;
            }
            return(stream);
        }
Esempio n. 20
0
        public override bool EndTryReceive(IAsyncResult result, out Message message)
        {
            CompletedAsyncResult <bool, Message> completedResult = result as CompletedAsyncResult <bool, Message>;

            if (null != completedResult)
            {
                return(CompletedAsyncResult <bool, Message> .End(result, out message));
            }
            else
            {
                bool receiveSuccessful = base.EndTryReceive(result, out message);
                if (receiveSuccessful && message != null && this.receiveContextEnabled)
                {
                    message.Properties[ReceiveContext.Name] = new MsmqSessionReceiveContext(this);
                    Interlocked.Increment(ref incompleteMessageCount);
                }

                return(receiveSuccessful);
            }
        }
 private void OnConnectionEndSend(IAsyncResult result)
 {
     if (result is CompletedAsyncResult)
     {
         CompletedAsyncResult.End(result);
     }
     else
     {
         Exception exception;
         Message   reply = ReliableBinderRequestAsyncResult.End(result, out exception);
         ReliableBinderRequestAsyncResult result2 = (ReliableBinderRequestAsyncResult)result;
         if (result2.MessageAttemptInfo.RetryCount == this.settings.MaxRetryCount)
         {
             this.maxRetryCountException = exception;
         }
         if (reply != null)
         {
             this.ProcessReply(reply, (IReliableRequest)result2.MessageAttemptInfo.State, result2.MessageAttemptInfo.GetSequenceNumber());
         }
     }
 }
Esempio n. 22
0
        bool System.ServiceModel.Channels.IInputChannel.EndTryReceive(IAsyncResult result, out Message wcfMessage)
        {
            BrokeredMessage brokeredMessage;

            if (result is DoneAsyncResult)
            {
                wcfMessage = null;
                return(CompletedAsyncResult <bool> .End(result));
            }
            bool flag = this.OnEndTryReceive(result, out brokeredMessage);

            if (brokeredMessage == null)
            {
                wcfMessage = null;
            }
            else
            {
                wcfMessage = this.ConvertToWcfMessage(brokeredMessage);
                this.TraceReceivedMessage(wcfMessage);
            }
            return(flag);
        }
Esempio n. 23
0
 public void OnEndOuterListenerClose(IAsyncResult result)
 {
     if (result is CompletedAsyncResult)
     {
         CompletedAsyncResult.End(result);
     }
     else
     {
         bool flag = false;
         try
         {
             this.innerListener.EndClose(result);
             flag = true;
         }
         finally
         {
             if (!flag)
             {
                 this.innerListener.Abort();
             }
         }
     }
 }
        public TSingleton EndGetInstance(IAsyncResult asyncResult)
        {
            TSingleton tSingleton;

            if (asyncResult is SingletonManager <TSingleton> .SingletonValidAsyncResult)
            {
                tSingleton = CompletedAsyncResult <TSingleton> .End(asyncResult);
            }
            else if (!(asyncResult is SingletonManager <TSingleton> .AsyncWaiter))
            {
                tSingleton = default(TSingleton);
                Exception exception = null;
                try
                {
                    try
                    {
                        tSingleton = this.OnEndCreateInstance(asyncResult);
                    }
                    catch (Exception exception1)
                    {
                        exception = exception1;
                        throw;
                    }
                }
                finally
                {
                    this.CompleteWaiters(tSingleton, exception);
                }
            }
            else if (!SingletonManager <TSingleton> .AsyncWaiter.End(asyncResult, out tSingleton))
            {
                throw Fx.Exception.AsWarning(new TimeoutException(), null);
            }
            this.OnGetInstance(tSingleton);
            return(tSingleton);
        }
Esempio n. 25
0
 public virtual SecurityToken EndReadTokenCore(IAsyncResult result)
 {
     return(CompletedAsyncResult <SecurityToken> .End(result));
 }
 protected override void OnEndOpen(IAsyncResult result)
 {
     CompletedAsyncResult.End(result);
 }
Esempio n. 27
0
 protected internal virtual void OnEndWorkflowCompleted(IAsyncResult result)
 {
     CompletedAsyncResult.End(result);
 }
 protected override void EndInitializeChannelFactories(IAsyncResult result)
 {
     CompletedAsyncResult.End(result);
 }
Esempio n. 29
0
 protected internal virtual bool EndTryCommand(IAsyncResult result)
 {
     return(CompletedAsyncResult <bool> .End(result));
 }
 protected virtual void EndOnLoad(IAsyncResult result)
 {
     CompletedAsyncResult.End(result);
 }