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.
This commit is contained in:
Jack251970 2025-11-06 15:39:19 +08:00
parent bfaff5cca5
commit d0a47c84b9
2 changed files with 3 additions and 3 deletions

View file

@ -49,7 +49,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
public static async ValueTask<bool> 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

View file

@ -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<Win32> 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<UWPApp> uwps;
await _uwpsLock.WaitAsync();