From 190f096a8b7094dd387fba93ec0826c187baa4d8 Mon Sep 17 00:00:00 2001 From: martincostello Date: Tue, 27 Jun 2023 09:44:29 +0100 Subject: [PATCH] Add comment to clarify Add comment as requested in peer review. --- src/Polly.Core/Utils/TimeProviderExtensions.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Polly.Core/Utils/TimeProviderExtensions.cs b/src/Polly.Core/Utils/TimeProviderExtensions.cs index 64ad3a565b..3f6e4c4eb5 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