From 740d3bbccc96c9759a4ad08d8b6fcf76b0ba7e11 Mon Sep 17 00:00:00 2001 From: Ben Olden-Cooligan Date: Wed, 6 Mar 2024 20:09:09 -0800 Subject: [PATCH] Set invoker in entry points --- NAPS2.Lib.WinForms/EtoForms/WinForms/WinFormsEtoPlatform.cs | 1 - NAPS2.Lib/EntryPoints/ConsoleEntryPoint.cs | 1 + NAPS2.Lib/EntryPoints/GuiEntryPoint.cs | 1 + NAPS2.Lib/EtoForms/EtoPlatform.cs | 2 -- 4 files changed, 2 insertions(+), 3 deletions(-) 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(); }