NamedPipeServerStream C# proper usage - I keep getting IOExceptions
I've been searching for a while but it seems to be difficult to find any definite answers on how to 开发者_运维百科recover from exceptions thrown by calling NamedPipeServerStream.BeginWaitForConnection. I have an application that sets up a named pipe server on a well known name and listens for messages to perform certain actions.
It works fine and dandy until the application is restarted. This usually results in an IOException saying, "The pipe is being closed." How can I correctly recover from this exception and use the same name for my named pipe? Any good resources on a good production worthy implementation of a named pipe server would be appreciated.
If you're sending the message immediately after starting the process. You should call wait for pipe drain before closing the handle. Make sure to WaitForPipeDrain
on the stream before close.
- Good luck!
精彩评论