From e9d8579bbd4e06e49f3d16fe6e84043ff2d727f2 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sat, 3 Dec 2022 13:50:30 -0600 Subject: [PATCH] fix concurrency issue (really potentially) --- .../Search/Everything/EverythingAPI.cs | 8 +++++--- 1 file changed, 5 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 4df2e6b08..5381d729d 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs @@ -91,9 +91,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything public static async ValueTask IsEverythingRunningAsync(CancellationToken token = default) { + await _semaphore.WaitAsync(token); + try { - await _semaphore.WaitAsync(token); EverythingApiDllImport.Everything_GetMajorVersion(); var result = EverythingApiDllImport.Everything_GetLastError() != StateCode.IPCError; return result; @@ -119,10 +120,11 @@ 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); + + try { - await _semaphore.WaitAsync(token); - if (token.IsCancellationRequested) yield break;