diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs index 966ef7602..4df2e6b08 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs @@ -19,9 +19,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything private const int BufferSize = 4096; - private static SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); + private static SemaphoreSlim _semaphore = new(1, 1); // cached buffer to remove redundant allocations. - private static readonly StringBuilder buffer = new StringBuilder(BufferSize); + private static readonly StringBuilder buffer = new(BufferSize); public enum StateCode { @@ -118,14 +118,13 @@ 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); - - if (token.IsCancellationRequested) - yield break; - + try { + await _semaphore.WaitAsync(token); + + if (token.IsCancellationRequested) + yield break; if (option.Keyword.StartsWith("@")) {