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

Caching the CancellationToken will prevent ObjectDisposedException race condition #2125

Merged
merged 1 commit into from
May 19, 2024

Conversation

jstnlef
Copy link
Contributor

@jstnlef jstnlef commented May 18, 2024

To be a good citizen, it is important that the caller of this method can (and should) call Dispose() on the returned token source. The problem though, is that each time cts.Token was called before, it would try to create a new CancellationToken which means that it could throw an ObjectDisposedException leading to noisy logs.

To be a good citizen, it is important that the caller of this method can (and should) call Dispose() on the returned token source. The problem though, is that each time cts.Token was called before, it would try to create a new CancellationToken which means that it could throw an ObjectDisposed exception leading to noisy logs.
@rogeralsing rogeralsing merged commit e8ba0f6 into asynkron:dev May 19, 2024
14 checks passed
@jstnlef jstnlef deleted the cache-cts-token-for-dispose branch May 19, 2024 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants