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

Fix: Dispose CancellationTokenSource Properly Within CancellationDisposable #1

Closed
wants to merge 1 commit into from
Closed

Fix: Dispose CancellationTokenSource Properly Within CancellationDisposable #1

wants to merge 1 commit into from

Conversation

denis-kondratev
Copy link

@denis-kondratev denis-kondratev commented Oct 19, 2023

Fixes the issue where the CancellationTokenSource created within CancellationDisposable is not properly disposed of. For more details, see Issue #535.

Clarification on the following code block:

if (!IsDisposed)
{
    _cts.Cancel();
}

The Dispose() method is designed to be idempotent, allowing for multiple invocations. If a CancellationTokenSource object is created inside CancellationDisposable and gets disposed during the initial call to Dispose(), subsequent attempts to cancel it will result in an exception.

@denis-kondratev denis-kondratev changed the title Fix CancellationDisposable Fix: Dispose CancellationTokenSource Properly Within CancellationDisposable Oct 19, 2023
if (!IsDisposed)
{
_cts.Cancel();
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Dispose() method is designed to be idempotent, allowing for multiple invocations. If a CancellationTokenSource object is created inside CancellationDisposable and gets disposed during the initial call to Dispose(), subsequent attempts to cancel it will result in an exception.

@denis-kondratev
Copy link
Author

Upps

@denis-kondratev denis-kondratev deleted the fix-cancellationdisposable branch October 20, 2023 06:52
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.

1 participant