Skip to content

Instantly share code, notes, and snippets.

@thaianhduc
Created October 1, 2018 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thaianhduc/4dd0c54c8daf5810835d032bce51a438 to your computer and use it in GitHub Desktop.
Save thaianhduc/4dd0c54c8daf5810835d032bce51a438 to your computer and use it in GitHub Desktop.
A simple caller without allowing consumers to handle exceptions
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