Example #1
0
        public void RunReadMessageLoop()
        {
            try
            {
                var messageStream = new MessageStream(InStream);

                while (true)
                {
                    var message = messageStream.ReadMessage();
                    if (message == MessageStream.EndOfStream)
                    {
                        break;
                    }

                    ThreadPool.QueueUserWorkItem(o => HandleMessage(message));
                }
            }
            catch (System.IO.IOException ex)
            {
                Log.Error("Reading failed.", ex);
            }
            catch (ObjectDisposedException)
            {
                // Can ignore this, means the other endpoint closed the pipe
            }
        }
        private static NamedPipeClientStream CreateOutputStream(NamedPipeServerStream srv)
        {
            var stream      = new MessageStream(srv);
            var outPipeName = stream.ReadMessage();
            var outStream   = new NamedPipeClientStream(".", outPipeName, PipeDirection.Out);

            outStream.Connect(2000);
            return(outStream);
        }