Given the following code:
var cts = new CancellationTokenSource();
try
{
// get a \"hot\" task
var task = new HttpClient().GetAsync(\"http://www.go
I set the timeout to infinite to disable it, then I pass in my own cancellation token.
using(CancellationTokenSource cancelAfterDelay = new CancellationTokenSource(timespan/timeout))
...
catch(OperationCanceledException e)
{
if(!cancelAfterDelay.Token.IsCancellationRequested)
throw new TimeoutException($"An HTTP request to {request.Uri} timed out ({(int)requestTimeout.TotalSeconds} seconds)");
else
throw;
}