Created
March 22, 2012 18:50
-
-
Save eulerfx/2161734 to your computer and use it in GitHub Desktop.
Function retry logic
This file contains 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
public static Func<T> Retry(Func<T> original, int retryCount) | |
{ | |
return () => | |
{ | |
while (true) | |
{ | |
try | |
{ | |
return original(); | |
} | |
catch (Exception e) | |
{ | |
if (retryCount == 0) | |
{ | |
throw; | |
} | |
retryCount--; | |
} | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment