fix concurrency issue (really potentially)

This commit is contained in:
Hongtao Zhang 2022-12-03 13:50:30 -06:00
parent 4a0ee9b4fc
commit e9d8579bbd
No known key found for this signature in database
GPG key ID: 75F655B91C7AC9BB

View file

@ -91,9 +91,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
public static async ValueTask<bool> 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;