private void LogServiceThread() { NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", "GISGMPXMLPacketSignerPipe", PipeDirection.InOut, PipeOptions.Asynchronous); if (pipeClient.IsConnected != true) { pipeClient.Connect(); } // Logger.Instance.logToFile = false; StreamReaderWriter stream = new StreamReaderWriter(pipeClient); if (stream.ReadLine() == "How are you?") { stream.WriteLine("I am Client! ept!"); stream.Flush(); pipeClient.WaitForPipeDrain(); /*string s = stream.ReadLine();*/ tbLog.BeginInvoke((MethodInvoker)(() => tbLog.Clear())); Logger.Instance.logToFile = false; while (pipeClient.IsConnected && !stopLogServiceThread) { string str = stream.ReadLine(); if (str != String.Empty) { LogAsIs(str); } } if (pipeClient.IsConnected) { stream.WriteLine("Goodbye!"); stream.Flush(); pipeClient.WaitForPipeDrain(); } pipeClient.Close(); } }
public void PoolToPipe(string str) { try { if (pipeServer.IsConnected) { stream.WriteLine(str); stream.Flush(); pipeServer.WaitForPipeDrain(); } } catch (IOException E) { Log("Не удалось передать сообщение клиенту. Клиент отключился. " + E.Message); } }