Skip to content

[Foundation] Dispose method freeing managed resource #6915

Closed

Description

@prmallic

Following the Dispose standard, one shouldn't need to dispose CancellationTokenSource in the InflightData class here -

protected virtual void Dispose (bool disposing)
{
    if (disposing) {
        if (CancellationTokenSource != null) {
            CancellationTokenSource.Dispose ();
            CancellationTokenSource = null;
        }
    }
}

Activity

  1. added
    enhancement
    on Sep 5, 2019
  2. added
    iOS
    macOS
    on Sep 5, 2019
  3. added this to the Future milestone on Sep 5, 2019
  4. added
    networking
    on Oct 19, 2026
  5. rolfbjarne commented on Oct 29, 2026

    @rolfbjarne
    Member

    Already addressed by #20328, merged March 19, 2024. That change removed InflightData.Dispose and its CancellationTokenSource.Dispose() call to prevent ObjectDisposedException when late NSURLSession callbacks still access the cancellation source (see #11799).

    For clarity, disposing owned managed IDisposable resources in Dispose(true) is generally correct; the reason for removing disposal here was the callback lifetime race, not that the resource is managed.

    Note

    This comment was generated by GitHub Copilot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementiOSmacOSnetworking

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions