From db0c86d50ceeaee66c415d88922ac4c0f6a843c9 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Tue, 4 Nov 2025 14:25:55 +0800 Subject: [PATCH] Remove CancellationToken from semaphore WaitAsync calls Removed the `CancellationToken` parameter from `WaitAsync` calls on semaphores in `EverythingAPI.cs` and `Main.cs`. This change eliminates cancellation support for semaphore waits, likely due to a design decision prioritizing simplicity or avoiding issues with cancellation handling. In `EverythingAPI.cs`, `WaitAsync(token)` was replaced with `WaitAsync()` in two methods. Similarly, in `Main.cs`, the `WaitAsync` calls for `_win32sLock` and `_uwpsLock` were updated to remove the `token` parameter. Note: This change may impact the ability to gracefully handle cancellation during semaphore waits. --- .../Search/Everything/EverythingAPI.cs | 5 ++--- Plugins/Flow.Launcher.Plugin.Program/Main.cs | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs index fd62566d5..8e295b960 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs @@ -48,7 +48,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything public static async ValueTask IsEverythingRunningAsync(CancellationToken token = default) { - await _semaphore.WaitAsync(token); + await _semaphore.WaitAsync(); try { @@ -77,8 +77,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything if (option.MaxCount < 0) throw new ArgumentOutOfRangeException(nameof(option.MaxCount), option.MaxCount, "MaxCount must be greater than or equal to 0"); - await _semaphore.WaitAsync(token); - + await _semaphore.WaitAsync(); try { diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs index 79f169642..201062aa6 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs @@ -86,10 +86,10 @@ namespace Flow.Launcher.Plugin.Program Context.API.LogDebug(ClassName, $"Cache miss for query: {query.Search}"); var resultList = await Task.Run(async () => { - Context.API.LogDebug(ClassName, "Acquiring locks for querying programs"); - await _win32sLock.WaitAsync(token); Context.API.LogDebug(ClassName, "Acquiring locks for querying win32 programs"); - await _uwpsLock.WaitAsync(token); + await _win32sLock.WaitAsync(); + Context.API.LogDebug(ClassName, "Acquiring locks for querying uwp programs"); + await _uwpsLock.WaitAsync(); Context.API.LogDebug(ClassName, "Locks acquired for querying programs"); try {