-
Notifications
You must be signed in to change notification settings - Fork 113
Use CancellationToken in AsyncExecution
#1531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use CancellationToken in AsyncExecution
#1531
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the timeout logic in AsyncExecution to use cancellation tokens instead of the previous Task.Wait(timeout) approach. The changes introduce linked cancellation token sources that combine caller-provided cancellation with timeout-based cancellation, and distinguish between explicit cancellation and timeouts via exception filtering.
- Adds
CancellationTokenparameter with default value for better API ergonomics - Uses
CancellationTokenSource.CreateLinkedTokenSourceto chain timeout and caller cancellation - Implements exception filtering to convert timeout-based
OperationCanceledExceptiontoTimeoutException
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1531 +/- ##
=====================================
Coverage 90.3% 90.3%
=====================================
Files 418 418
Lines 35299 35301 +2
Branches 2188 2187 -1
=====================================
+ Hits 31876 31879 +3
- Misses 2980 2981 +1
+ Partials 443 441 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
aee3084 to
5464d92
Compare
5464d92 to
af86d53
Compare
This change refactors the timeout logic in
AsyncExecutionto use cancellation tokens. The changes modernize the way timeouts are handled for both asynchronous and void-returning methods, ensuring that timeouts trigger cancellation and throw aTimeoutExceptionas expected.