What is a good way to shutdown Threads blocked on NamedPipeServer#WaitForConnection?

后端 未结 7 2398
误落风尘
误落风尘 2020-12-01 10:02

I start my application which spawns a number of Threads, each of which creates a NamedPipeServer (.net 3.5 added managed types for Named Pipe IPC) and waits for clients to

7条回答
  •  青春惊慌失措
    2020-12-01 10:41

    Switch to the asynchronous version: BeginWaitForConnection.

    If it does ever complete, you'll need a flag so the completion handler can just call EndWaitForConnection absorbing any exceptions and exiting (call End... to ensure any resources are able to be cleaned up).

提交回复
热议问题