PipeClient.cs 722 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.IO.Pipes;
  3. namespace Xilium.CefGlue.Common.Shared.RendererProcessCommunication
  4. {
  5. internal class PipeClient : IDisposable {
  6. private readonly NamedPipeClientStream _pipe;
  7. public PipeClient(string pipeName)
  8. {
  9. _pipe = new NamedPipeClientStream(".", pipeName, PipeDirection.Out, PipeOptions.None);
  10. _pipe.Connect((int) TimeSpan.FromSeconds(10).TotalMilliseconds);
  11. }
  12. public void SendMessage(string message)
  13. {
  14. var stream = new PipeStream(_pipe);
  15. stream.WriteString(message);
  16. }
  17. public void Dispose()
  18. {
  19. _pipe.Close();
  20. _pipe.Dispose();
  21. }
  22. }
  23. }