I have multithreaded operation which performs a series of tasks. The problem i'm facing is a webservice that might return an Timeout when under heavy stress.
When under heavy stress (Timeout), I want the function to retry
Try
{
// Do some actions here
}
catch(WebException ex)
{
if (// Timeout)
{ //Retry }
else
{ // return error }
}
catch(Exception ex)
{ //return error }
From MSDN An Webexception can occur in the following situations:
- Abort was previously called.
- The time-out period for the request expired.
- An error occurred while processing the request.
Question:
In my exceptionhandling, how can seperate these 3 causes and single out the TimeoutExceptions
without using the message?
Note: I know i could just increase the timeout
to resolve the issue. But that doesn't statify my curiosity.
Thank you for your time