Skip to content

AsyncCollectionRequestMessage<T> creates a CancellationTokenSource that never gets disposed #1117

@jphorv-bdo

Description

@jphorv-bdo

Describe the bug

I was examining the code for the the AsyncCollectionRequestMessage class and I noticed it creates a private CancellationTokenSource that never gets Dispose() called on it.

I looked at CancellationTokenSource's dispose methods and it's non-trivial, potentially disposing of a System.ITimer and a ManualResetEvent - both things that are potentially finite resources, so better to release ASAP.

Regression

No response

Steps to reproduce

No reproduction, just observation of the code.

Expected behavior

There should be an opportunity to dispose the CancellationTokenSource. Most obvious possible way would be to make thing that comes to mind would be make AsyncCollectionRequestMessage<T> implement IDispose so that users could call it.

Screenshots

No response

IDE and version

VS 2022

IDE version

17.14.11

Nuget packages

  • CommunityToolkit.Common
  • CommunityToolkit.Diagnostics
  • CommunityToolkit.HighPerformance
  • CommunityToolkit.Mvvm (aka MVVM Toolkit)

Nuget package version(s)

8.4.0

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛An unexpected issue that highlights incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions