public static void DoStreamOperations(PipeStream stream)
{
if (stream.CanWrite)
{
stream.Write(new byte[] { 123, 124 }, 0, 2);
}
if (stream.CanRead)
{
if (stream.ReadByte() != 123)
{
Console.WriteLine("First byte read != 123");
}
if (stream.ReadByte() != 124)
{
Console.WriteLine("Second byte read != 124");
}
}
Console.WriteLine("*** Operations finished. ***");
}