private static void PipesReader(string pipeName)
{
try
{
using (var pipeReader = new NamedPipeServerStream(pipeName, PipeDirection.In))
{
pipeReader.WaitForConnection();
WriteLine("reader connected");
const int BUFFERSIZE = 256;
bool completed = false;
while (!completed)
{
byte[] buffer = new byte[BUFFERSIZE];
int nRead = pipeReader.Read(buffer, 0, BUFFERSIZE);
string line = Encoding.UTF8.GetString(buffer, 0, nRead);
WriteLine(line);
if (line == "bye") completed = true;
}
}
WriteLine("completed reading");
ReadLine();
}
catch (Exception ex)
{
WriteLine(ex.Message);
}
}