public FastChannel(string name, bool isOwner, Module module)
        {
            _module = module;  // Types belonging to this module will serialize faster

            DomainAddress = (byte)(isOwner ? 1 : 2);

            _outPipe = new OutPipe(name + (isOwner ? ".A" : ".B"), isOwner);
            _inPipe  = new InPipe(name + (isOwner ? ".B" : ".A"), isOwner, OnMessageReceived);
        }
        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();
                }
        }
        void StressTestReceive(CancellationToken cancelToken)
        {
            SHA1      hasher = SHA1.Create();
            const int hashLength = 20;
            int       successes = 0, failures = 0;
            var       start        = Stopwatch.StartNew();
            bool      firstMessage = true;

            var inPipe = new InPipe("test", true, msg =>
            {
                if (firstMessage)
                {
                    start.Restart();
                }
                firstMessage = false;

                var hash = hasher.ComputeHash(msg, 0, msg.Length - hashLength);

                if (hash.SequenceEqual(msg.Skip(msg.Length - hashLength)))
                {
                    successes++;
                }
                else
                {
                    failures++;
                }

                if ((successes + failures) % 1000 == 0)
                {
                    Console.WriteLine("Successes: " + successes);
                    Console.WriteLine("Failures: " + failures);
                    Console.WriteLine("Performance:" + Math.Round(successes / start.Elapsed.TotalSeconds, 0) + " messages per second.");
                }

                Console.SetCursorPosition(0, 0);
            });

            cancelToken.Register(() => inPipe.Dispose());
        }