From d0a47c84b9b5641330af13808cac387bfa458b2e Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 6 Nov 2025 15:39:19 +0800 Subject: [PATCH] Clarify CancellationToken handling in comments Updated comments to explain the rationale for not directly passing CancellationToken to methods and instead checking IsCancellationRequested within locks. This prevents unexpected OperationCanceledException. Changes made in EverythingAPI.cs (IsEverythingRunningAsync) and Main.cs (Win32 and UWP program preparation). No functional changes to the code. --- .../Search/Everything/EverythingAPI.cs | 2 +- Plugins/Flow.Launcher.Plugin.Program/Main.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs index c8f8de77f..d06fdfa98 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs @@ -49,7 +49,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything public static async ValueTask IsEverythingRunningAsync(CancellationToken token = default) { // We do not directly pass token here, but we check IsCancellationRequested inside the lock - // So that it will not raise OperationCanceledException, which is not expected by the caller.` + // So that it will not raise OperationCanceledException, which is not expected by the caller. await _semaphore.WaitAsync(); try diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs index 6a8b404b5..aac5de2c2 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs @@ -85,7 +85,7 @@ namespace Flow.Launcher.Plugin.Program var resultList = await Task.Run(async () => { // We do not directly pass token here, but we check IsCancellationRequested inside the lock - // So that it will not raise OperationCanceledException, which is not expected by the caller.` + // So that it will not raise OperationCanceledException, which is not expected by the caller. Context.API.LogDebug(ClassName, "Preparing win32 programs"); List win32s; await _win32sLock.WaitAsync(); @@ -100,7 +100,7 @@ namespace Flow.Launcher.Plugin.Program } // We do not directly pass token here, but we check IsCancellationRequested inside the lock - // So that it will not raise OperationCanceledException, which is not expected by the caller.` + // So that it will not raise OperationCanceledException, which is not expected by the caller. Context.API.LogDebug(ClassName, "Preparing UWP programs"); List uwps; await _uwpsLock.WaitAsync();