This code illustrates the blog article Better timeout handling with HttpClient.
Key features:
- control the timeout per request, rather than globally for all requests
- throw a more sensible exception (
TimeoutException
) when a timeout occurs, instead of the usualOperationCanceledException
@bitm0de I don't find it more convenient myself, but if you prefer that approach, by all means go ahead and use it 😉