Skip to content

Commit e9d8579

Browse files
committed
fix concurrency issue (really potentially)
1 parent 4a0ee9b commit e9d8579

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ public static bool IsFastSortOption(SortOption sortOption)
9191

9292
public static async ValueTask<bool> IsEverythingRunningAsync(CancellationToken token = default)
9393
{
94+
await _semaphore.WaitAsync(token);
95+
9496
try
9597
{
96-
await _semaphore.WaitAsync(token);
9798
EverythingApiDllImport.Everything_GetMajorVersion();
9899
var result = EverythingApiDllImport.Everything_GetLastError() != StateCode.IPCError;
99100
return result;
@@ -119,10 +120,11 @@ public static async IAsyncEnumerable<SearchResult> SearchAsync(EverythingSearchO
119120
if (option.MaxCount < 0)
120121
throw new ArgumentOutOfRangeException(nameof(option.MaxCount), option.MaxCount, "MaxCount must be greater than or equal to 0");
121122

123+
await _semaphore.WaitAsync(token);
124+
125+
122126
try
123127
{
124-
await _semaphore.WaitAsync(token);
125-
126128
if (token.IsCancellationRequested)
127129
yield break;
128130

0 commit comments

Comments
 (0)