Is it possible to cancel the BeginRead on the NamedPipeServerStream without closing the pipe?
What the title says, really.
I have a named pipe. I would like to try to read, but if it fails after the timeout, I would still be able to use this channel later.
Is this possible with NamedPipeServerStream
, or do I need to rethink the whole approach?
So far, the only way to cancel BeginRead
is to remove it from the channel.
a source to share
BeginRead
returns IAsyncResult
commits this to the scope of the class.
Then, create a timer with the required timeout, in the callback method call EndRead
, passing IAsyncResult
in the returned from the initial one BeginRead
.
Edit: I am doing some research and the best solution I have found is to get rid of the ServerStream (which does destroy the Pipe itself).
a source to share