public void BasicTest() { var str = "Test1Test2Test3"; var text = new TextBuffer(); var reader = text.GetReader(); var evt = new AutoResetEvent(false); Action a = () => { evt.WaitOne(); text.Write(str); evt.WaitOne(); text.Write(str); }; var t = new Thread(new ThreadStart(a)); t.Start(); char[] buffer = new char[0x1000]; 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); var reader2 = text.GetReader(); evt.Set(); var task2 = reader2.ReadToEndAsync(); task.Wait(); task2.Wait(); s = task.Result; var s2 = task2.Result; Assert.True(!string.IsNullOrEmpty(s2)); log.WriteLine(s.ToString()); log.WriteLine(s2.ToString()); t.Join(); }