Skip to content

Add CancellationTokenSource disposal to CleanUp method#553

Closed
Copilot wants to merge 2 commits intomilly/idispfrom
copilot/sub-pr-545
Closed

Add CancellationTokenSource disposal to CleanUp method#553
Copilot wants to merge 2 commits intomilly/idispfrom
copilot/sub-pr-545

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

Addresses feedback from #545 to ensure CancellationTokenSource is disposed in all cleanup paths.

Changes

  • Added explicit cts?.Dispose() and cts = null to CleanUp() method in KnowledgeRetrieval.xaml.cs

While CancelResponse() already disposes cts, the explicit disposal in CleanUp() provides defense against future refactoring and makes the cleanup contract clear.

private void CleanUp()
{
    CancelResponse();
    _model?.Dispose();
    _indexer?.RemoveAll();
    _indexer?.Dispose();
    _indexer = null;
    cts?.Dispose();  // Added
    cts = null;       // Added
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: weiyuanyue <176483933+weiyuanyue@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 8, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aiinfra.pkgs.visualstudio.com
    • Triggering command: /usr/bin/dotnet dotnet build AIDevGallery.sln -c Release --verbosity quiet (dns block)
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.23.8/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp /opt/hostedtoolcache/CodeQL/2.23.8/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp (dns block)
    • Triggering command: /usr/bin/dotnet dotnet restore --no-dependencies /home/REDACTED/work/ai-dev-gallery/ai-dev-gallery/AIDevGallery.Utils/AIDevGallery.Utils.csproj --packages /home/REDACTED/work/ai-dev-gallery/.codeql-scratch/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/home/REDACTED/work/ai-dev-gallery/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/home/REDACTED/work/ai-dev-gallery/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Address feedback on IDisposable Analyzer Warnings PR Add CancellationTokenSource disposal to CleanUp method Jan 8, 2026
Copilot AI requested a review from weiyuanyue January 8, 2026 16:17
@weiyuanyue weiyuanyue closed this Jan 8, 2026
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