mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Error handling for OperationCancelledException in Program plugin
This commit is contained in:
parent
69cb8e6147
commit
6e9e51ec4d
1 changed files with 27 additions and 12 deletions
|
|
@ -47,20 +47,35 @@ namespace Flow.Launcher.Plugin.Program
|
|||
win32 = _win32s;
|
||||
uwps = _uwps;
|
||||
|
||||
|
||||
var result = await Task.Run(delegate
|
||||
try
|
||||
{
|
||||
return win32.Cast<IProgram>()
|
||||
.Concat(uwps)
|
||||
.AsParallel()
|
||||
.WithCancellation(token)
|
||||
.Where(p => p.Enabled)
|
||||
.Select(p => p.Result(query.Search, _context.API))
|
||||
.Where(r => r?.Score > 0)
|
||||
.ToList();
|
||||
}, token).ConfigureAwait(false);
|
||||
var result = await Task.Run(delegate
|
||||
{
|
||||
try
|
||||
{
|
||||
return win32.Cast<IProgram>()
|
||||
.Concat(uwps)
|
||||
.AsParallel()
|
||||
.WithCancellation(token)
|
||||
.Where(p => p.Enabled)
|
||||
.Select(p => p.Result(query.Search, _context.API))
|
||||
.Where(r => r?.Score > 0)
|
||||
.ToList();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}, token).ConfigureAwait(false);
|
||||
|
||||
return result;
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task InitAsync(PluginInitContext context)
|
||||
|
|
|
|||
Loading…
Reference in a new issue