What bugs me when working with class NamedPipeServerStream
is that for every incoming connection I need to create new object and call it's method WaitForConnection
.
What I want to do is to create one NamedPipeServerStream
object, and then repeatedly in a while loop call aforementioned method, like that:
NamedPipeServerStream s2;
using (s2 = new NamedPipeServerStream("pipe_name", PipeDirection.InOut)) {
while(true) {
ss2.WaitForConnection();
//do something here
}
}
But when I do this, I get message
Stream has been disconnected.
Any advice?