Пример #1
0
        IAsyncResult BeginPoll(MakeConnectionDuplexClientChannel <TChannel> channel, AsyncCallback callback, object state)
        {
            TChannel channelToUse = channel.GetChannelForPoll();

            this.outstandingPoll = new PollAsyncResult <TChannel>(channel, channelToUse, callback, state);
            return(this.outstandingPoll);
        }
Пример #2
0
        void AbortOutstandingPolls()
        {
            PollAsyncResult <TChannel> pollToAbort = this.outstandingPoll;

            if (pollToAbort != null)
            {
                pollToAbort.Abort();
            }
        }
Пример #3
0
            public static Message End(IAsyncResult result)
            {
                PollAsyncResult <TChannel> thisPtr = AsyncResult.End <PollAsyncResult <TChannel> >(result);

                if (thisPtr.pollingMessage != null)
                {
                    thisPtr.pollingMessage.Close();
                }

                return(thisPtr.returnMessage);
            }
Пример #4
0
        void EndPoll(IAsyncResult result)
        {
            Message message = null;

            try
            {
                this.outstandingPoll = null;
                message = PollAsyncResult <TChannel> .End(result);

                if (message != null && message.IsFault)
                {
                    MessageFault fault = MessageFault.CreateFault(message, MakeConnectionConstants.Defaults.MaxFaultSize);
                    MakeConnectionMessageFault wsmcFault;

                    if (MakeConnectionMessageFault.TryCreateFault(message, fault, out wsmcFault))
                    {
                        throw MakeConnectionMessageFault.CreateException(wsmcFault);
                    }
                }
            }
            catch (TimeoutException)
            {
            }
            catch (Exception e)
            {
                EnqueueException(e);
            }

            if (message != null)
            {
                MakeConnectionDuplexClientChannel <TChannel> channelToDispatch = this.channel;
                if (channelToDispatch != null)
                {
                    channelToDispatch.EnqueueAndDispatch(message, null, false);
                }
            }

            lock (ThisLock)
            {
                polling = false;

                if (this.channel != null && !stopPolling)
                {
                    ThreadPool.QueueUserWorkItem(onEnsurePollingLater, this);
                }
                else
                {
                    this.pollingComplete.Set();
                }
            }
        }
Пример #5
0
            static void OnRequestComplete(IAsyncResult result)
            {
                if (result.CompletedSynchronously)
                {
                    return;
                }

                PollAsyncResult <T> thisPtr = (PollAsyncResult <T>)result.AsyncState;

                Exception completionException = null;

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

                thisPtr.Complete(false, completionException);
            }