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;
|
win32 = _win32s;
|
||||||
uwps = _uwps;
|
uwps = _uwps;
|
||||||
|
|
||||||
|
try
|
||||||
var result = await Task.Run(delegate
|
|
||||||
{
|
{
|
||||||
return win32.Cast<IProgram>()
|
var result = await Task.Run(delegate
|
||||||
.Concat(uwps)
|
{
|
||||||
.AsParallel()
|
try
|
||||||
.WithCancellation(token)
|
{
|
||||||
.Where(p => p.Enabled)
|
return win32.Cast<IProgram>()
|
||||||
.Select(p => p.Result(query.Search, _context.API))
|
.Concat(uwps)
|
||||||
.Where(r => r?.Score > 0)
|
.AsParallel()
|
||||||
.ToList();
|
.WithCancellation(token)
|
||||||
}, token).ConfigureAwait(false);
|
.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)
|
public async Task InitAsync(PluginInitContext context)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue