Named Pipes - Asynchronous Peeking

前端 未结 2 589
既然无缘
既然无缘 2021-02-08 17:27

I need to find a way to be notified when a System.IO.Pipe.NamedPipeServerStream opened in asynchronous mode has more data available for reading on it- a WaitHandle would be idea

2条回答
  •  独厮守ぢ
    2021-02-08 18:06

    Looking through MSDN, I don't see any mechanism to do what you want. The quickest solution is porbably to use interop to access PeekNamedPipe. If you don't want to use interop, you can abstract the pipe inside a custom class and provide the peek functionality within the abstraction. The abstraction would handle all the signaling and have to coordinate reading and writing to the pipe. Obviously, not a trivial task.

    Another alternative, if possible in your situation, is to look into using WCF which is pretty much that abstraction.

提交回复
热议问题