Skip to content

Commit 190f096

Browse files
Add comment to clarify
Add comment as requested in peer review.
1 parent 8dc6e8c commit 190f096

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Polly.Core/Utils/TimeProviderExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ public static Task DelayAsync(this TimeProvider timeProvider, TimeSpan delay, Re
2525

2626
if (context.IsSynchronous)
2727
{
28-
#pragma warning disable CA1849 // For synchronous scenarios we want to return completed task
28+
#pragma warning disable CA1849
29+
// For synchronous scenarios we want to return a completed task. We avoid
30+
// the use of Thread.Sleep() here because it is not cancellable and to
31+
// simplify the code. Sync-over-async is not a concern here because it
32+
// only applies in the case of a reilience event and not on the hot path.
2933
timeProvider.Delay(delay, context.CancellationToken).GetAwaiter().GetResult();
3034
#pragma warning restore CA1849
3135

0 commit comments

Comments
 (0)