Skip to content

Making your own Retry Interval

Cleve Littlefield edited this page Feb 1, 2016 · 2 revisions

Retry interval is just a Func<int, TimeSpan>. The int is the current retry count and the return is a timespan.

To specify a built in retry interval, just pass in a function:

var retryPolicy = new RetryPolicy((exception) => exception is TimeOutException, 5, RetryIntervalFactory.GetExponentialInterval(100));

The built in fixed interval just returns the same interval every time, linear returns the interval * the retry count, and exponentional return 2^(the retry count)*interval.

If you have a custom retry interval in mind, just create your own function that returns a Func<int, TimeSpan>.

So whatever other logic you can think of is possible by passing a custom function to the RetryPolicy.

Clone this wiki locally