public void ReadTest()
        {
            var stream = new SharedMemoryStream();

            var buffer = new byte[10000];

            stream.Write(buffer, 0, 10000);
            Assert.Equal(10000, stream.Length);

            var reader = stream.GetReader();
            var b = new byte[1];
            while (reader.Read(b, 0, 1) != 0) {

            }

            Assert.Equal(10000, reader.Position);
        }
        public void BasicTest()
        {
            var data = new byte[0x1000];

            var buffer = new byte[0x1000];

            var oStream = new SharedMemoryStream();
            var reader = oStream.GetReader();

            var evt = new AutoResetEvent(false);

            Action a = () =>
            {
                evt.WaitOne();
                oStream.Write(data, 0, 16);
                evt.WaitOne();
                oStream.Write(data, 0, 16);
            };

            var t = new Thread(new ThreadStart(a));
            t.Start();

            var task = reader.ReadAsync(buffer, 0, 1000);
            evt.Set();
            task.Wait();
            var s = task.Result;
            log.WriteLine(s.ToString());

            task = reader.ReadAsync(buffer, 0, 1000);

            evt.Set();

            task.Wait();
            s = task.Result;
            log.WriteLine(s.ToString());
            t.Join();
        }