From 096410f3d4f49d747de942b13dba47b1e406715c Mon Sep 17 00:00:00 2001 From: Kang Yu Date: Sun, 26 Jun 2022 18:13:29 -0700 Subject: [PATCH] experiment to fix asynchronous GUI operation using BeginInvoke() --- .../Program.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Ninjacrab.PersistentWindows.Solution/Ninjacrab.PersistentWindows.SystrayShell/Program.cs b/Ninjacrab.PersistentWindows.Solution/Ninjacrab.PersistentWindows.SystrayShell/Program.cs index 33a9ca7..34a5e3a 100755 --- a/Ninjacrab.PersistentWindows.Solution/Ninjacrab.PersistentWindows.SystrayShell/Program.cs +++ b/Ninjacrab.PersistentWindows.Solution/Ninjacrab.PersistentWindows.SystrayShell/Program.cs @@ -308,12 +308,24 @@ namespace Ninjacrab.PersistentWindows.SystrayShell static void EnableRestoreMenu(bool enableRestoreDB, bool checkUpgrade) { - systrayForm.UpdateMenuEnable(enableRestoreDB, checkUpgrade); + if (systrayForm.InvokeRequired) + systrayForm.BeginInvoke((Action) delegate () + { + systrayForm.UpdateMenuEnable(enableRestoreDB, checkUpgrade); + }); + else + systrayForm.UpdateMenuEnable(enableRestoreDB, checkUpgrade); } static void EnableRestoreSnapshotMenu(bool enable) { - systrayForm.EnableSnapshotRestore(enable); + if (systrayForm.InvokeRequired) + systrayForm.BeginInvoke((Action) delegate () + { + systrayForm.EnableSnapshotRestore(enable); + }); + else + systrayForm.EnableSnapshotRestore(enable); } static public void CaptureSnapshot(int id, bool prompt = true)