private static void ExecuteThread() { Debug.WriteLine("\n*** Named pipe server stream starting (" + Program.PROCESS_PIPE_NAME + ") ***\n"); var pipeServer = new NamedPipeServerStream(Program.PROCESS_PIPE_NAME, PipeDirection.InOut, 1); int threadId = Thread.CurrentThread.ManagedThreadId; while (run) { pipeServer.WaitForConnection(); try { StreamString ss = new StreamString(pipeServer); var incoming = ss.ReadString(); Debug.WriteLine("Incoming command from pipe: " + incoming); ss.WriteString("OK"); pipeServer.Disconnect(); if (incoming.Length <= 0) { continue; } string[] commandParts = incoming.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); CommandProcessor.Process(commandParts); } catch (IOException e) { Debug.WriteLine("\n*** ERROR - Named pipe server stream failed, exception details follow [will try to continue] (" + Program.PROCESS_PIPE_NAME + ") ***\n\n {0} \n\n", e.Message); try { pipeServer.Disconnect(); } catch (Exception) { } } } }
public string Read() { var ss = new StreamString(pipeClient); return(ss.ReadString()); }
public string Read() { var ss = new StreamString(pipeClient); return ss.ReadString(); }