Reputation: 3695
Are there any classes in the .Net framework which implement pipes, but for inter thread communication instead of interprocess communication? System.IO.Pipes
seems overkill.
Specifically what I'm looking for is something that allows a single reader thread and a single writer thread, and allows blocking IO on both the read and write sides of the pipe. System.IO.Pipes.PipeStream
seems overboard.
Additionally, ideally, the writer would be able to "write" exceptions to the pipe, which would cause any reader to wake up, and any additional reads would throw the exception "pushed" through the pipe.
Note that I'm looking for something that implements the System.IO.Stream
interfaces. I'm strictly trying to send a stream of data, not necessarily "messages". The reason for wanting a stream interface, is that I would like the reader to be able to treat the incoming data like any other source.
Upvotes: 1
Views: 609
Reputation: 59302
Use a Monitor. It has a Wait() method for the reader and a Pulse() method for the writer.
Communication is done via the object that is passed as an argument.
Upvotes: 1