Skip to content
Discussion options

You must be logged in to vote

Thanks for the suggestion, but we've discussed this before and don't want to do it. CancellationToken has a strong guarantee that once it transitions to having cancellation requested, it'll never transition back, and such use would break that guarantee. You can, of course, reuse a CTS as many times as you'd like if it hasn't yet had cancellation requested (and if it has, the associated costs almost always are orders of magnitude larger than what you'd potentially save by pooling), subject to whatever guarantees your own code provides, and we added TryReset in .NET 6 to make that easier, in particular in the face of timeouts.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@timcassell
Comment options

Answer selected by timcassell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants