diff --git a/src/Polly.Core/Utils/TimeProviderExtensions.cs b/src/Polly.Core/Utils/TimeProviderExtensions.cs index 64ad3a565bf..3f6e4c4eb55 100644 --- a/src/Polly.Core/Utils/TimeProviderExtensions.cs +++ b/src/Polly.Core/Utils/TimeProviderExtensions.cs @@ -25,7 +25,11 @@ public static Task DelayAsync(this TimeProvider timeProvider, TimeSpan delay, Re if (context.IsSynchronous) { -#pragma warning disable CA1849 // For synchronous scenarios we want to return completed task +#pragma warning disable CA1849 + // For synchronous scenarios we want to return a completed task. We avoid + // the use of Thread.Sleep() here because it is not cancellable and to + // simplify the code. Sync-over-async is not a concern here because it + // only applies in the case of a reilience event and not on the hot path. timeProvider.Delay(delay, context.CancellationToken).GetAwaiter().GetResult(); #pragma warning restore CA1849