SyntaxHighlighter

Sunday, July 13, 2008

Named pipes issue: WaitForConnection hangs around indefinitely

I recently created an IPC client and server based on the newish NamedPipeServerStream and NamedPipeClientStream classes in .NET 3.x.

It worked great, but when trying to stop the server, the main thread would hang aound waiting for the WaitForConnection() statement to return. I tried to kill the thread in a number of ways, but to no avail.

In the end, I created an easy workaround by doing a "dummy" client connection to the server. This will cause WaitForConnection() method to continue and the thread can then be stopped gracefully.

No comments: