Skip to content

Commit 4a0ee9b

Browse files
committed
fix concurrency issue (potentially)
1 parent 605db60 commit 4a0ee9b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public static class EverythingApi
1919

2020
private const int BufferSize = 4096;
2121

22-
private static SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
22+
private static SemaphoreSlim _semaphore = new(1, 1);
2323
// cached buffer to remove redundant allocations.
24-
private static readonly StringBuilder buffer = new StringBuilder(BufferSize);
24+
private static readonly StringBuilder buffer = new(BufferSize);
2525

2626
public enum StateCode
2727
{
@@ -118,14 +118,13 @@ public static async IAsyncEnumerable<SearchResult> SearchAsync(EverythingSearchO
118118

119119
if (option.MaxCount < 0)
120120
throw new ArgumentOutOfRangeException(nameof(option.MaxCount), option.MaxCount, "MaxCount must be greater than or equal to 0");
121-
122-
await _semaphore.WaitAsync(token);
123-
124-
if (token.IsCancellationRequested)
125-
yield break;
126-
121+
127122
try
128123
{
124+
await _semaphore.WaitAsync(token);
125+
126+
if (token.IsCancellationRequested)
127+
yield break;
129128

130129
if (option.Keyword.StartsWith("@"))
131130
{

0 commit comments

Comments
 (0)