Created
May 22, 2013 21:49
-
-
Save mwadams/5631223 to your computer and use it in GitHub Desktop.
Example RetryStrategy
This file contains hidden or 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 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