diff --git a/NAPS2.Lib.WinForms/EtoForms/WinForms/WinFormsEtoPlatform.cs b/NAPS2.Lib.WinForms/EtoForms/WinForms/WinFormsEtoPlatform.cs index ba269fdf2..8deb5d955 100644 --- a/NAPS2.Lib.WinForms/EtoForms/WinForms/WinFormsEtoPlatform.cs +++ b/NAPS2.Lib.WinForms/EtoForms/WinForms/WinFormsEtoPlatform.cs @@ -37,7 +37,6 @@ public class WinFormsEtoPlatform : EtoPlatform application.MainForm = mainForm; mainForm.Show(); var appContext = new WF.ApplicationContext(mainForm.ToNative()); - Invoker.Current = new WinFormsInvoker(() => appContext.MainForm!); WinFormsDesktopForm.ApplicationContext = appContext; var setOptionsMethod = typeof(ApplicationHandler).GetMethod("SetOptions", BindingFlags.Instance | BindingFlags.NonPublic); diff --git a/NAPS2.Lib/EntryPoints/ConsoleEntryPoint.cs b/NAPS2.Lib/EntryPoints/ConsoleEntryPoint.cs index eb1f8b8b9..fbf9fc020 100644 --- a/NAPS2.Lib/EntryPoints/ConsoleEntryPoint.cs +++ b/NAPS2.Lib/EntryPoints/ConsoleEntryPoint.cs @@ -50,6 +50,7 @@ public static class ConsoleEntryPoint var application = EtoPlatform.Current.CreateApplication(); application.UnhandledException += UnhandledException; application.Initialized += (_, _) => scanning.Execute().ContinueWith(_ => application.Quit()); + Invoker.Current = new EtoInvoker(application); EtoPlatform.Current.RunApplication(application); } else diff --git a/NAPS2.Lib/EntryPoints/GuiEntryPoint.cs b/NAPS2.Lib/EntryPoints/GuiEntryPoint.cs index ff2e1083c..8feca0a44 100644 --- a/NAPS2.Lib/EntryPoints/GuiEntryPoint.cs +++ b/NAPS2.Lib/EntryPoints/GuiEntryPoint.cs @@ -38,6 +38,7 @@ public static class GuiEntryPoint // Show the main form var application = EtoPlatform.Current.CreateApplication(); application.UnhandledException += UnhandledException; + Invoker.Current = new EtoInvoker(application); var formFactory = container.Resolve(); var desktop = formFactory.Create(); diff --git a/NAPS2.Lib/EtoForms/EtoPlatform.cs b/NAPS2.Lib/EtoForms/EtoPlatform.cs index 6943f5b69..ee2b3ac03 100644 --- a/NAPS2.Lib/EtoForms/EtoPlatform.cs +++ b/NAPS2.Lib/EtoForms/EtoPlatform.cs @@ -39,13 +39,11 @@ public abstract class EtoPlatform public virtual void RunApplication(Application application, Form mainForm) { - Invoker.Current = new EtoInvoker(application); application.Run(mainForm); } public virtual void RunApplication(Application application) { - Invoker.Current = new EtoInvoker(application); application.Run(); }