Skip to content

Instantly share code, notes, and snippets.

@emiaj
Created July 8, 2011 13:58
Show Gist options
  • Select an option

  • Save emiaj/1071886 to your computer and use it in GitHub Desktop.

Select an option

Save emiaj/1071886 to your computer and use it in GitHub Desktop.
try{
DoSomething();
}
catch
{
}
const int maxAttempts = 3;
bool success = false;
for(var i = 0; i < maxAttempts; i++)
{
if(success){
break;
}
try{
DoSomething();
success = true;
}
catch(My.Application.ServerUnavailableException ex){
retries++;
if(retries > maxAttempts ){
throw;
}
Thread.Sleep(500);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment