Question

I have an application that runs a NamedPipeServerStream in a thread and waits for connections on it like so:

NamedPipeServerStream pipeServerTemp = new NamedPipeServerStream(PIP_NAME, PipeDirection.InOut, 254);
pipeServerTemp.WaitForConnection();

The application is always waiting for new connections, but when I try to kill the app the process hangs on the call to WaitForConnection.

I've tried aborting the thread in question but it doesn't kill the application.

How can I tell the NamedPipeServerStream to stop listening for connections?

EDIT:

I can see that NamedPipeServerStream has a method called EndWaitForConnection but it needs a reference to an IAsynchResult, where would I get that object?

Was it helpful?

Solution

Found the solution I was looking for in the answer to another question.

For what it's worth I went for the simple solution of connecting to the Stream and then immediately closing the connection rather than making it asynchronous.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top