开发者

NamedPipeServerStream C# proper usage - I keep getting IOExceptions

开发者 https://www.devze.com 2023-01-18 16:29 出处:网络
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.BeginWaitForConnecti

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消