using System.Collections;
using System.Collections.Generic;
public static void Main()
Retry.Do(() => ReIssue(), TimeSpan.FromSeconds(1), 5);
private static void ReIssue()
throw new Exception("Hello World");
public static class Retry
public static void Do(Action action, TimeSpan retryInterval, int maxAttemptCount = 3)
, retryInterval, maxAttemptCount);
public static T Do<T>(Func<T> action, TimeSpan retryInterval, int maxAttemptCount = 3)
var exceptions = new List<Exception>();
for (int attempted = 0; attempted < maxAttemptCount; attempted++)
Thread.Sleep(retryInterval);
throw new AggregateException(exceptions);