using Polly; public static class ResilienceExt { public static void WithRetry(this Action operation, int retryCount = 3, int delayMs = 150) => Policy.Handle() .WaitAndRetry(retryCount, num => TimeSpan.FromMilliseconds(num * delayMs), (exception, timeSpan) => Console.WriteLine($"Exception: {exception}, TimeSpan: {timeSpan}")) .Execute(operation); public static TResult WithRetry(this Func operation, int retryCount = 3, int delayMs = 150) => Policy.Handle() .WaitAndRetry(retryCount, num => TimeSpan.FromMilliseconds(num * delayMs)) .Execute(operation); }