Skip to content
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

Check CancellationToken before TimeSpan in TimeProviderTaskExtensions #107009

Merged
merged 3 commits into from
Sep 5, 2024

Conversation

brantburnett
Copy link
Contributor

This makes the down-level behavior for Delay and WaitAsync match the behavior in .NET 8 and later, prefering to return a Canceled task over a Completed task or TimeoutException when the TimeSpan is Zero and the CancellationToken is already Canceled.

Fixes #106996

…sions

This makes the down-level behavior for Delay and WaitAsync match the
behavior in .NET 8 and later, prefering to return a Canceled task over
a Completed task or TimeoutException when the TimeSpan is Zero and the
CancellationToken is already Canceled.

Fixes dotnet#106996
@tarekgh
Copy link
Member

tarekgh commented Sep 4, 2024

CC @stephentoub

@tarekgh
Copy link
Member

tarekgh commented Sep 5, 2024

/ba-g the failing test looks infrastructure without any logs.

@tarekgh tarekgh merged commit 36e6b42 into dotnet:main Sep 5, 2024
79 of 85 checks passed
@tarekgh
Copy link
Member

tarekgh commented Sep 5, 2024

Thanks @brantburnett for your help with this change.

@tarekgh
Copy link
Member

tarekgh commented Sep 5, 2024

/backport to release/9.0

Copy link
Contributor

github-actions bot commented Sep 5, 2024

Started backporting to release/9.0: https://github.com/dotnet/runtime/actions/runs/10725729170

@brantburnett brantburnett deleted the time-provider-delay branch September 13, 2024 12:40
jtschuster pushed a commit to jtschuster/runtime that referenced this pull request Sep 17, 2024
…dotnet#107009)

* Check CancellationToken before TimeSpan.Zero in TimeProviderTaskExtensions

This makes the down-level behavior for Delay and WaitAsync match the
behavior in .NET 8 and later, prefering to return a Canceled task over
a Completed task or TimeoutException when the TimeSpan is Zero and the
CancellationToken is already Canceled.

Fixes dotnet#106996

* Test improvements based on feedback

---------

Co-authored-by: Tarek Mahmoud Sayed <10833894+tarekgh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.DateTime community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Down-level TimeProviderTaskExtensions CancellationToken behavior is inconsistent with Task
4 participants