protected override void DisposeCore()
 {
     base.DisposeCore();
     lock (_proxiesLock)
     {
         _proxiesByID.Clear();
         _proxiesByObject.Clear();
     }
     _inPipe.Dispose();
     _outPipe.Dispose();
 }
        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());
        }