Replies: 2 comments 1 reply
-
This is by design. The work item is queued rather than invoked synchronously so that all of the work after the await doesn't happen synchronously as part of the call to Cancel. |
Beta Was this translation helpful? Give feedback.
1 reply
-
You can reaplace the line |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In our unit tests we use certain behavior of CancellationToken. After upgrading from .NET 6.0 to .NET 7.0 several tests failed. The reason is change in the behavior which can be easily explained with the following code.
In .NET 6.0 is the output True but in .NET 7.0 is the output False. Interestingly if I use a different task
var task = Task.Delay(1000, cts.Token);
the behavior is consistent across both .NET versions and outputs True.
Is this intended? Currently we use workaround of Thread.Sleep(10) before checking task.IsCanceled.
Beta Was this translation helpful? Give feedback.
All reactions