c# - NetworkStream ReadAsync cancellation -
this question has answer here:
i trying add "timeout" readasync method networkstream.
i want cancel readasync after specific time.
for example:
ctstimeout.cancelafter(10); int bytesread = await nsstream.readasync(newarr, 0, newarr.length, ctstimeout.token); but method still waiting response server.
is possible cancel method in reading state?
networkstream (or stream inheritance) doesn't support cancellation. readasync method accepts cancellation token, sure; allows know if cancellation requested before read completed. readasync wraps beginread , endread--which offer no way cancel read operation.
to cancel read need dispose or close networkstream object.
Comments
Post a Comment