diff --git a/NAPS2.Lib.Gtk/EtoForms/Ui/GtkDesktopForm.cs b/NAPS2.Lib.Gtk/EtoForms/Ui/GtkDesktopForm.cs index b4297ada98..4e57a437d4 100644 --- a/NAPS2.Lib.Gtk/EtoForms/Ui/GtkDesktopForm.cs +++ b/NAPS2.Lib.Gtk/EtoForms/Ui/GtkDesktopForm.cs @@ -71,8 +71,6 @@ public GtkDesktopForm( protected override void OnLoad(EventArgs e) { - // TODO: What's the best place to initialize this? It needs to happen from the UI event loop. - Invoker.Current = new SyncContextInvoker(SynchronizationContext.Current!); base.OnLoad(e); var listView = (GtkListView) _listView; listView.NativeControl.StyleContext.AddClass("desktop-listview"); diff --git a/NAPS2.Lib.Mac/EtoForms/Ui/MacDesktopForm.cs b/NAPS2.Lib.Mac/EtoForms/Ui/MacDesktopForm.cs index db7fe09609..c56845d58a 100644 --- a/NAPS2.Lib.Mac/EtoForms/Ui/MacDesktopForm.cs +++ b/NAPS2.Lib.Mac/EtoForms/Ui/MacDesktopForm.cs @@ -38,13 +38,6 @@ public MacDesktopForm( _thumbnailController.Oversample = 2.0; } - protected override void OnLoad(EventArgs e) - { - // TODO: What's the best place to initialize this? It needs to happen from the UI event loop. - Invoker.Current = new SyncContextInvoker(SynchronizationContext.Current!); - base.OnLoad(e); - } - protected override void UpdateTitle(ScanProfile? defaultProfile) { Title = UiStrings.Naps2; diff --git a/NAPS2.Lib/EtoForms/EtoPlatform.cs b/NAPS2.Lib/EtoForms/EtoPlatform.cs index bf3a6ad101..ef00a73a7f 100644 --- a/NAPS2.Lib/EtoForms/EtoPlatform.cs +++ b/NAPS2.Lib/EtoForms/EtoPlatform.cs @@ -38,12 +38,12 @@ public virtual void InitializePlatform() public virtual void RunApplication(Application application, Form mainForm) { + Invoker.Current = new EtoInvoker(application); application.Run(mainForm); } public virtual void RunApplication(Application application) { - // TODO: Can we use EtoInvoker more generally and get rid of some of the platform-specific stuff? Invoker.Current = new EtoInvoker(application); application.Run(); } diff --git a/NAPS2.Sdk/Threading/SyncContextInvoker.cs b/NAPS2.Sdk/Threading/SyncContextInvoker.cs deleted file mode 100644 index f3451bf8d2..0000000000 --- a/NAPS2.Sdk/Threading/SyncContextInvoker.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Threading; - -namespace NAPS2.Threading; - -internal class SyncContextInvoker : IInvoker -{ - private readonly SynchronizationContext _current; - - public SyncContextInvoker(SynchronizationContext current) - { - _current = current; - } - - public void Invoke(Action action) - { - _current.Send(_ => action(), null); - } - - public void InvokeDispatch(Action action) - { - _current.Post(_ => action(), null); - } - - public T InvokeGet(Func func) - { - T value = default!; - _current.Send(_ => value = func(), null); - return value; - } -} \ No newline at end of file