diff --git a/Terminal.Gui/App/Application.Lifecycle.cs b/Terminal.Gui/App/Application.Lifecycle.cs
index 7a487ae09..cf4985c2f 100644
--- a/Terminal.Gui/App/Application.Lifecycle.cs
+++ b/Terminal.Gui/App/Application.Lifecycle.cs
@@ -157,11 +157,8 @@ public static partial class Application // Lifecycle (Init/Shutdown)
MainThreadId = Thread.CurrentThread.ManagedThreadId;
bool init = Initialized = true;
- // Raise InitializedChanged event via the instance
- if (ApplicationImpl.Instance is ApplicationImpl impl)
- {
- impl.RaiseInitializedChanged (init);
- }
+ // Raise InitializedChanged event
+ OnInitializedChanged (null, new (init));
}
internal static void SubscribeDriverEvents ()
@@ -247,15 +244,13 @@ public static partial class Application // Lifecycle (Init/Shutdown)
///
/// Intended to support unit tests that need to know when the application has been initialized.
///
- public static event EventHandler>? InitializedChanged
+ public static event EventHandler>? InitializedChanged;
+
+ ///
+ /// Raises the event.
+ ///
+ internal static void OnInitializedChanged (object sender, EventArgs e)
{
- add
- {
- ApplicationImpl.Instance.InitializedChanged += value;
- }
- remove
- {
- ApplicationImpl.Instance.InitializedChanged -= value;
- }
+ InitializedChanged?.Invoke (sender, e);
}
}
diff --git a/Terminal.Gui/App/ApplicationImpl.cs b/Terminal.Gui/App/ApplicationImpl.cs
index decbfe5d8..de2dd186f 100644
--- a/Terminal.Gui/App/ApplicationImpl.cs
+++ b/Terminal.Gui/App/ApplicationImpl.cs
@@ -204,15 +204,12 @@ public class ApplicationImpl : IApplication
}
}
- ///
- public event EventHandler>? InitializedChanged;
-
///
- /// Internal helper to raise InitializedChanged event. Used by legacy Init path.
+ /// Internal helper to raise InitializedChanged event. Used by legacy Init path and modern Init path.
///
internal void RaiseInitializedChanged (bool initialized)
{
- InitializedChanged?.Invoke (null, new (initialized));
+ Application.OnInitializedChanged (this, new (initialized));
}
///
@@ -305,7 +302,7 @@ public class ApplicationImpl : IApplication
_initialized = true;
- InitializedChanged?.Invoke (this, new (true));
+ Application.OnInitializedChanged (this, new (true));
Application.SubscribeDriverEvents ();
SynchronizationContext.SetSynchronizationContext (new ());
@@ -504,7 +501,7 @@ public class ApplicationImpl : IApplication
if (wasInitialized)
{
bool init = _initialized; // Will be false after clearing fields above
- InitializedChanged?.Invoke (this, new (in init));
+ Application.OnInitializedChanged (this, new (in init));
}
_lazyInstance = new (() => new ApplicationImpl ());
diff --git a/Terminal.Gui/App/IApplication.cs b/Terminal.Gui/App/IApplication.cs
index 7bd9839b6..958c7fbf6 100644
--- a/Terminal.Gui/App/IApplication.cs
+++ b/Terminal.Gui/App/IApplication.cs
@@ -271,14 +271,6 @@ public interface IApplication
/// Gets all cultures supported by the application without the invariant language.
List? SupportedCultures { get; }
- ///
- /// This event is raised after the and methods have been called.
- ///
- ///
- /// Intended to support unit tests that need to know when the application has been initialized.
- ///
- event EventHandler>? InitializedChanged;
-
///
/// Resets the application state to defaults. This is called by .
///