c# - NetworkStream ReadAsync cancellation -
this question has answer here: networkstream.readasync cancellation token never cancels 4 answers 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.