Example #1
0
        public void AsyncProcessRequest(IClientChannelSinkStack stack,
                                        IMessage msg,
                                        ITransportHeaders headers,
                                        Stream stream)
        {
            DBG.Info(null, "Async: Send the message across the pipe");

            PipeConnection _pipe = SendWithRetry(msg, headers, stream);

            IMethodCallMessage mcm        = (IMethodCallMessage)msg;
            MethodBase         methodBase = mcm.MethodBase;
            bool oneway = RemotingServices.IsOneWay(methodBase);

            if (oneway)
            {
                if (_pipeConnectionPool != null)
                {
                    _pipeConnectionPool.ReturnToPool(_pipe);
                }
                _pipe = null;
            }
            else
            {
                PipeConnectionCookie cookie = new PipeConnectionCookie();

                cookie.pipe      = _pipe;
                cookie.sinkStack = stack;

                //TODO Switch to use Completion port
                ThreadPool.QueueUserWorkItem(callback, cookie);
            }
        }
Example #2
0
        private void ReceiveCallback(Object state)
        {
            //Console.WriteLine("ReceiveCallback TID {0}", Thread.CurrentThread.GetHashCode());

            PipeConnectionCookie cookie = (PipeConnectionCookie)state;

            PipeConnection          _pipe     = cookie.pipe;
            IClientChannelSinkStack sinkStack = cookie.sinkStack;

            try
            {
                // Read response
                //
                _pipe.BeginReadMessage();

                ITransportHeaders responseHeaders = _pipe.ReadHeaders();
                responseHeaders["__CustomErrorsEnabled"] = false;

                Stream responseStream = _pipe.ReadStream();
                _pipe.EndReadMessage();

                if (_pipeConnectionPool != null)
                {
                    _pipeConnectionPool.ReturnToPool(_pipe);
                }

                _pipe = null;

                sinkStack.AsyncProcessResponse(responseHeaders, responseStream);
            }
            catch (Exception e)
            {
                try
                {
                    if (sinkStack != null)
                    {
                        sinkStack.DispatchException(e);
                    }
                }
                catch (Exception)
                {
                    // Fatal Error.. ignore
                }
            }
        } // ReceiveCallback
Example #3
0
        public void AsyncProcessRequest(IClientChannelSinkStack stack, 
                                        IMessage msg,
                                        ITransportHeaders headers, 
                                        Stream stream)
        {
            DBG.Info(null, "Async: Send the message across the pipe");

            PipeConnection _pipe = SendWithRetry(msg, headers, stream);

            IMethodCallMessage mcm = (IMethodCallMessage)msg;
            MethodBase methodBase = mcm.MethodBase;
            bool oneway = RemotingServices.IsOneWay(methodBase);

            if (oneway)
            {
                if (_pipeConnectionPool != null)
                {
                    _pipeConnectionPool.ReturnToPool(_pipe);
                }
                _pipe = null;
            }
            else
            {
                PipeConnectionCookie cookie = new PipeConnectionCookie();

                cookie.pipe = _pipe;
                cookie.sinkStack = stack;

                //TODO Switch to use Completion port
                ThreadPool.QueueUserWorkItem(callback, cookie);
            }
        }