Skip to content

ExecuteAsync with ResilienceContext and CancellationToken #2133

Discussion options

You must be logged in to vote

Polly v7 had far too many method overloads which made future iteration and maintenance difficult, so we rationalised down the number of overloads for v8. We also made other changes to improve performance, such as pooling contexts.

If you want to use both features (context and cancellation) then the shared snippet is the way to achieve this. You could simplify the code to some degree by adding helper methods specific to your context to do things like get/set your values on your ResilienceContext via methods that abstract away the resilience keys etc: example.

The inner token in the lambda will/should be different if you're using strategies like timeout and hedging, so I would avoid writing…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@AndrejNazarov
Comment options

@martincostello
Comment options

@AndrejNazarov
Comment options

@martincostello
Comment options

Answer selected by AndrejNazarov
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants