Skip to content

Instantly share code, notes, and snippets.

@johnib
Created April 28, 2017 13:34
Show Gist options
  • Save johnib/c642c2f71c0ae08305cacddf22163217 to your computer and use it in GitHub Desktop.
Save johnib/c642c2f71c0ae08305cacddf22163217 to your computer and use it in GitHub Desktop.
class Program
{
static void Main(string[] args)
{
var someClassInstance = new SomeClass();
someClassInstance.DoSomething();
}
}
class Retry : Attribute
{
private static readonly Policy DefaultRetryPolicy = Policy
.Handle<Exception>()
.WaitAndRetry(3, retryAttempt => TimeSpan.FromSeconds(5));
public void Wrapper(Action action)
{
DefaultRetryPolicy.Execute(action);
}
}
class SomeClass
{
[Retry]
public void DoSomething()
{
// core logic
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment