29 lines
703 B
C#
29 lines
703 B
C#
using System.ComponentModel;
|
|
using System.IO.Pipes;
|
|
|
|
namespace NamedPipes
|
|
{
|
|
public class NamedPipeClient : NamedPipe
|
|
{
|
|
protected override void Run(object sender, DoWorkEventArgs args)
|
|
{
|
|
try
|
|
{
|
|
var pipe = new NamedPipeClientStream(
|
|
serverName: ".",
|
|
pipeName: PIPE_NAME,
|
|
direction: PipeDirection.InOut,
|
|
options: PipeOptions.Asynchronous);
|
|
this.pipe = pipe;
|
|
|
|
pipe.Connect();
|
|
base.Run(sender, args);
|
|
}
|
|
catch
|
|
{
|
|
base.Disconnect();
|
|
}
|
|
}
|
|
}
|
|
}
|