using System.ComponentModel; using System.IO.Pipes; namespace NamedPipes { public class NamedPipeServer : NamedPipe { protected override void Run(object sender, DoWorkEventArgs args) { try { var pipe = new NamedPipeServerStream( pipeName: PIPE_NAME, maxNumberOfServerInstances: 1, direction: PipeDirection.InOut, transmissionMode: PipeTransmissionMode.Byte, options: PipeOptions.Asynchronous); this.pipe = pipe; pipe.WaitForConnection(); base.Run(sender, args); } catch { base.Disconnect(); } } } }