Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2016
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. protected override void OnStart(string[] args)
  2.     {
  3.         new Thread(() =>
  4.         {
  5.             while (true)
  6.             {
  7.                 using (var pipe = new NamedPipeServerStream("test", PipeDirection.InOut, 1, PipeTransmissionMode.Byte))
  8.                 {
  9.                     var ps = new PipeSecurity();
  10.                     ps.AddAccessRule(new PipeAccessRule(WindowsIdentity.GetCurrent().Name, PipeAccessRights.FullControl, AccessControlType.Allow));
  11.                     pipe.SetAccessControl(ps);
  12.  
  13.                     pipe.WaitForConnection();
  14.                     int x = pipe.ReadByte();
  15.                     pipe.WriteByte((byte)(x + 1));
  16.                 }
  17.             }
  18.         })
  19.         { IsBackground = true }.Start();
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement