Sometimes, if my REST service takes very long, I get the following exception when invoking HttpClient.SendAsync(blah).Result:
System.AggregateException: One or more errors occurred. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task`1.get_Result()
Is there a way for me to explicitly check (based on exception type/info/other data) whether the task was canceled due to timeout? I'm not explicitly cancelling the task anywhere in my code, so at least I know for sure that the cancellation is being done
by the framework itself.
[Edit] I've already seen this thread: http://stackoverflow.com/questions/10547895/how-can-i-tell-when-httpclient-has-timed-out
Thanks,
Priya
Please "Mark as Answer" if this resolves your query. Thanks!
priya_marwah...
Member
81 Points
52 Posts
Is there a way to identify whether HttpClient timed out?
Dec 03, 2012 09:50 AM|LINK
Sometimes, if my REST service takes very long, I get the following exception when invoking HttpClient.SendAsync(blah).Result:
System.AggregateException: One or more errors occurred. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task`1.get_Result()
Is there a way for me to explicitly check (based on exception type/info/other data) whether the task was canceled due to timeout? I'm not explicitly cancelling the task anywhere in my code, so at least I know for sure that the cancellation is being done by the framework itself.
[Edit] I've already seen this thread: http://stackoverflow.com/questions/10547895/how-can-i-tell-when-httpclient-has-timed-out
Thanks,
Priya