private static PipeResponse Send(string operation, Dictionary<string, string> data, int timeout = 5000) { var packetOut = new Medo.Net.TinyPacket("VhdAttach", operation, data); try { Pipe.Open(); Pipe.Write(packetOut.GetBytes()); var timer = new Stopwatch(); timer.Start(); while (timer.ElapsedMilliseconds < timeout) { if (Pipe.HasBytesToRead) { break; } Thread.Sleep(100); } timer.Stop(); if (Pipe.HasBytesToRead) { var buffer = Pipe.ReadAvailable(); var packetIn = Medo.Net.TinyPacket.Parse(buffer); return new PipeResponse(bool.Parse(packetIn["IsError"]), packetIn["Message"]); } else { return new PipeResponse(true, "Cannot contact service."); } } finally { Pipe.Close(); } }