public byte[] Write(CommandId command) { byte[] result = null; using (MemoryStream ms = new MemoryStream()) { using (BinaryWriter bw = new BinaryWriter(ms)) { bw.Write((byte)command); } result = ms.ToArray(); } pipeServer.Send(result); return(result); }