I just be familiar with Polly and I'm trying to start with a simple Retry mechanism.
Here's the code:
static void Main(string[] args)
{
Policy
.Handle<NotImplementedException>()
.WaitAndRetry(5, retryAttempt => TimeSpan.FromSeconds(100), (exception, i, arg3) => Console.WriteLine(i))
.Execute(() => { Console.WriteLine(Do()); });
}
private static string Do()
{
return ++_counter < 3
? throw new NotImplementedException()
: "done";
}
}
I expected that the thrown NotImplementedException
caught by Polly and retried until desired result return. But at first exception raised the program stops! Where did I make a mistake?
Thanks in advance