Created
October 1, 2018 10:23
-
-
Save thaianhduc/4dd0c54c8daf5810835d032bce51a438 to your computer and use it in GitHub Desktop.
A simple caller without allowing consumers to handle exceptions
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 class ServiceCallHelper | |
{ | |
public TResult CallWithRetry<TResult>(Func<TResult> realCall, bool retry = true) | |
{ | |
try | |
{ | |
return realCall(); | |
} | |
catch (TimeoutException) | |
{ | |
if (retry) | |
return Retry(realCall); | |
throw; | |
} | |
} | |
private TResult Retry<TResult>(Func<TResult> realCall) | |
{ | |
return realCall(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment