Created
April 7, 2016 15:17
-
-
Save chadman/3938b2d07bba5fbe0f2c1728ff52f876 to your computer and use it in GitHub Desktop.
Invoke code with a retry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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