Skip to content

Commit d0a47c8

Browse files
committed
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.
1 parent bfaff5c commit d0a47c8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static bool IsFastSortOption(EverythingSortOption sortOption)
4949
public static async ValueTask<bool> IsEverythingRunningAsync(CancellationToken token = default)
5050
{
5151
// We do not directly pass token here, but we check IsCancellationRequested inside the lock
52-
// So that it will not raise OperationCanceledException, which is not expected by the caller.`
52+
// So that it will not raise OperationCanceledException, which is not expected by the caller.
5353
await _semaphore.WaitAsync();
5454

5555
try

Plugins/Flow.Launcher.Plugin.Program/Main.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
8585
var resultList = await Task.Run(async () =>
8686
{
8787
// We do not directly pass token here, but we check IsCancellationRequested inside the lock
88-
// So that it will not raise OperationCanceledException, which is not expected by the caller.`
88+
// So that it will not raise OperationCanceledException, which is not expected by the caller.
8989
Context.API.LogDebug(ClassName, "Preparing win32 programs");
9090
List<Win32> win32s;
9191
await _win32sLock.WaitAsync();
@@ -100,7 +100,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
100100
}
101101

102102
// We do not directly pass token here, but we check IsCancellationRequested inside the lock
103-
// So that it will not raise OperationCanceledException, which is not expected by the caller.`
103+
// So that it will not raise OperationCanceledException, which is not expected by the caller.
104104
Context.API.LogDebug(ClassName, "Preparing UWP programs");
105105
List<UWPApp> uwps;
106106
await _uwpsLock.WaitAsync();

0 commit comments

Comments
 (0)