Currently, we have a naive RetryWrapper that repeats the given function when an exception occurs:
public T Repeat<T, TException>(Func<T> work, TimeSpan retryInterval, int maxExecutionCount = 3) where TException : Exception
{
...
And for retryInterval, we use the following logic to βwaitβ before the next attempt.
_stopwatch.Start();
while (_stopwatch.Elapsed <= retryInterval)
{
// do nothing but actuallky it does! lots of CPU usage specially if retryInterval is high
}
_stopwatch.Reset();
I do not really like this logic, and ideally I would prefer the repetition logic NOT to happen in the main thread, can you come up with a better way?
Note. I will gladly review the answers to .Net> = 3.5
MaYaN source
share