Handle OperationCanceledException gracefully

Added a `catch` block for `OperationCanceledException` in
`PluginsManifest.cs` to ignore canceled operations. Updated
`EverythingAPI.cs` to use cancellation tokens with `_semaphore.WaitAsync`
and handle cancellations by exiting the method cleanly with `yield break`.
This commit is contained in:
Jack251970 2025-11-06 20:47:54 +08:00
parent 49f89e33b5
commit 88fd1e56d0
2 changed files with 12 additions and 1 deletions

View file

@ -54,6 +54,10 @@ namespace Flow.Launcher.Core.ExternalPlugins
return true;
}
}
catch (OperationCanceledException)
{
// Ignored
}
catch (Exception e)
{
PublicApi.Instance.LogException(ClassName, "Http request failed", e);

View file

@ -84,7 +84,14 @@ 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();
try
{
await _semaphore.WaitAsync(token);
}
catch (OperationCanceledException)
{
yield break;
}
try
{