What would the proper way to cancel TcpClient ReadAsync operation by timeout and catch this timeout event in .NET 4.5?
TcpClient.ReadTimeout seems to be applied to the sync Read only.
UPDATE:
Tried tro apply the approach desribed here Cancelling an Asynchronous Operation
var buffer = new byte[4096];
CancellationTokenSource cts = new CancellationTokenSource(5000);
int amountRead = await tcpClientStream.ReadAsync(buffer, 0, 4096, cts.Token);
but it never cancels by timeout. Is anything wrong?