Skip to content

Commit

Permalink
Merge pull request #3092 from Jack251970/dev3
Browse files Browse the repository at this point in the history
Fix System.OperationCanceledException Issue
  • Loading branch information
jjw24 authored Nov 24, 2024
2 parents 7e9ed8e + 9cb464d commit 9e46d3a
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions Plugins/Flow.Launcher.Plugin.Program/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,26 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
var result = await cache.GetOrCreateAsync(query.Search, async entry =>
{
var resultList = await Task.Run(() =>
_win32s.Cast<IProgram>()
.Concat(_uwps)
.AsParallel()
.WithCancellation(token)
.Where(HideUninstallersFilter)
.Where(p => p.Enabled)
.Select(p => p.Result(query.Search, Context.API))
.Where(r => r?.Score > 0)
.ToList());
{
try
{
return _win32s.Cast<IProgram>()
.Concat(_uwps)
.AsParallel()
.WithCancellation(token)
.Where(HideUninstallersFilter)
.Where(p => p.Enabled)
.Select(p => p.Result(query.Search, Context.API))
.Where(r => r?.Score > 0)
.ToList();
}
catch (OperationCanceledException)
{
Log.Debug("|Flow.Launcher.Plugin.Program.Main|Query operation cancelled");
return emptyResults;
}

}, token);

resultList = resultList.Any() ? resultList : emptyResults;

Expand Down

0 comments on commit 9e46d3a

Please sign in to comment.