Skip to content

Commit

Permalink
Fix CA1849 warning
Browse files Browse the repository at this point in the history
Fix CA1849 warning from updating snippets to .NET 9.
  • Loading branch information
martincostello committed Mar 1, 2024
1 parent 3be35d5 commit a29ccc2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions docs/strategies/retry.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,17 +710,15 @@ var ctsKey = new ResiliencePropertyKey<CancellationTokenSource>("cts");
var retry = new ResiliencePipelineBuilder()
.AddRetry(new()
{
OnRetry = args =>
OnRetry = async args =>
{
if (args.Outcome.Exception is TimeoutException)
{
if (args.Context.Properties.TryGetValue(ctsKey, out var cts))
{
cts.Cancel();
await cts.CancelAsync();
}
}

return ValueTask.CompletedTask;
}
})
.Build();
Expand Down
6 changes: 2 additions & 4 deletions src/Snippets/Docs/Retry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,15 @@ public static void AntiPattern_CancellingRetry()
var retry = new ResiliencePipelineBuilder()
.AddRetry(new()
{
OnRetry = args =>
OnRetry = async args =>
{
if (args.Outcome.Exception is TimeoutException)
{
if (args.Context.Properties.TryGetValue(ctsKey, out var cts))
{
cts.Cancel();
await cts.CancelAsync();
}
}
return ValueTask.CompletedTask;
}
})
.Build();
Expand Down

0 comments on commit a29ccc2

Please sign in to comment.