void Demo()
        {
            string pipeName = "test" + new Random().Next();

            using (var inPipe = new InPipe(pipeName, true, Console.WriteLine))
                using (var outPipe = new OutPipe(pipeName, false))
                {
                    outPipe.Write(new byte[] { 1, 2, 3 });
                    outPipe.Write(new byte[] { 1, 2, 3, 4, 5 });
                    Console.ReadLine();
                }
        }
        /// <summary>Instantiates an object remotely. To release it, you can either call Disconnect on the proxy returned
        /// or wait for its finalizer to do the same.s</summary>
        public Task <Proxy <TRemote> > Activate <TRemote>() where TRemote : class
        {
            lock (DisposeLock)
            {
                AssertSafe();
                int messageNumber = Interlocked.Increment(ref _lastMessageID);

                var ms     = new MemoryStream();
                var writer = new BinaryWriter(ms);
                writer.Write((byte)MessageType.Activation);
                writer.Write(messageNumber);
                SerializeType(writer, typeof(TRemote));
                writer.Flush();

                var task = GetResponseFuture <Proxy <TRemote> >(messageNumber);
                _outPipe.Write(ms.ToArray());

                return(task);
            }
        }
        void StressTestSend(CancellationToken cancelToken)
        {
            //Console.WriteLine("Running...");

            SHA1      hasher     = SHA1.Create();
            const int hashLength = 20;

            var random = new Random();
            var start  = Stopwatch.StartNew();

            using (var outPipe = new OutPipe("test", false))
                while (!cancelToken.IsCancellationRequested)
                {
                    int bufferLength = 20 + random.Next(60);
                    var buffer       = new byte[bufferLength + hashLength];
                    random.NextBytes(buffer);
                    var hash = hasher.ComputeHash(buffer, 0, bufferLength);
                    Array.Copy(hash, 0, buffer, bufferLength, hashLength);

                    outPipe.Write(buffer);
                }

            Console.WriteLine("Done");
        }