Skip to content

Commit 26c35a8

Browse files
committed
Fix use async
Signed-off-by: Florian Grabmeier <[email protected]>
1 parent dcaa74d commit 26c35a8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ await Http.DownloadAsync(x.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
305305
Title = Context.API.GetTranslation("plugin_pluginsmanager_update_all_title"),
306306
SubTitle = Context.API.GetTranslation("plugin_pluginsmanager_update_all_subtitle"),
307307
IcoPath = icoPath,
308-
Action = e =>
308+
AsyncAction = async e =>
309309
{
310310
string message;
311311
if (Settings.AutoRestartAfterChanging)
@@ -326,11 +326,11 @@ await Http.DownloadAsync(x.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
326326
return false;
327327
}
328328

329-
Parallel.ForEach(resultsForUpdate, plugin =>
329+
await Task.WhenAll(resultsForUpdate.Select(async plugin =>
330330
{
331331
var downloadToFilePath = Path.Combine(Path.GetTempPath(), $"{plugin.Name}-{plugin.NewVersion}.zip");
332332

333-
_ = Task.Run(async delegate
333+
try
334334
{
335335
if (File.Exists(downloadToFilePath))
336336
{
@@ -341,18 +341,17 @@ await Http.DownloadAsync(plugin.PluginNewUserPlugin.UrlDownload, downloadToFileP
341341
.ConfigureAwait(false);
342342

343343
PluginManager.UpdatePlugin(plugin.PluginExistingMetadata, plugin.PluginNewUserPlugin, downloadToFilePath);
344-
345-
}).ContinueWith(t =>
344+
}
345+
catch (Exception ex)
346346
{
347-
Log.Exception("PluginsManager", $"Update failed for {plugin.Name}",
348-
t.Exception.InnerException);
347+
Log.Exception("PluginsManager", $"Update failed for {plugin.Name}", ex.InnerException);
349348
Context.API.ShowMsg(
350349
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
351350
string.Format(
352351
Context.API.GetTranslation("plugin_pluginsmanager_install_error_subtitle"),
353352
plugin.Name));
354-
}, TaskContinuationOptions.OnlyOnFaulted);
355-
});
353+
}
354+
}));
356355

357356
if (Settings.AutoRestartAfterChanging)
358357
{

0 commit comments

Comments
 (0)