Skip to content

Instantly share code, notes, and snippets.

@chadman
Created April 7, 2016 15:17
Show Gist options
  • Save chadman/3938b2d07bba5fbe0f2c1728ff52f876 to your computer and use it in GitHub Desktop.
Save chadman/3938b2d07bba5fbe0f2c1728ff52f876 to your computer and use it in GitHub Desktop.
Invoke code with a retry
private T ActionWithRetry<T>(Func<T> fn) {
int retryCount = 0;
bool success = false;
while (retryCount < 4 && !success) {
try {
return fn();
}
catch (Exception e) {
retryCount++;
}
}
return default(T);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment