From f802d1524f94e12b1682cbe4d5b9671386f915ac Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Tue, 21 Jun 2022 22:44:25 -0400 Subject: [PATCH] make auto-scan more fault-tolerant --- Source/LibationWinForms/Form1.ScanAuto.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/LibationWinForms/Form1.ScanAuto.cs b/Source/LibationWinForms/Form1.ScanAuto.cs index 30cfa7e1..5fb10932 100644 --- a/Source/LibationWinForms/Form1.ScanAuto.cs +++ b/Source/LibationWinForms/Form1.ScanAuto.cs @@ -33,7 +33,18 @@ namespace LibationWinForms .ToArray(); // in autoScan, new books SHALL NOT show dialog - await Invoke(async () => await LibraryCommands.ImportAccountAsync(Login.WinformLoginChoiceEager.ApiExtendedFunc, accounts)); + try + { + Task importAsync() => LibraryCommands.ImportAccountAsync(Login.WinformLoginChoiceEager.ApiExtendedFunc, accounts); + if (InvokeRequired) + await Invoke(importAsync); + else + await importAsync(); + } + catch (Exception ex) + { + Serilog.Log.Logger.Error(ex, "Error invoking auto-scan"); + } }; // load init state to menu checkbox