Skip to content

Instantly share code, notes, and snippets.

@mwadams
Created May 22, 2013 21:49
Show Gist options
  • Save mwadams/5631223 to your computer and use it in GitHub Desktop.
Save mwadams/5631223 to your computer and use it in GitHub Desktop.
Example RetryStrategy
public class Count : RetryStrategy
{
private readonly int maxTries;
private int tryCount;
public Count()
: this(5)
{
}
public Count(int maxTries)
{
this.maxTries = maxTries;
}
public override bool CanRetry
{
get
{
return this.tryCount < this.maxTries;
}
}
public override TimeSpan PrepareToRetry(Exception lastException)
{
this.AddException(lastException);
this.tryCount += 1;
return TimeSpan.Zero;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment