This is probably very rare, but the WinForms Main()
method could for some reason look like this:
static bool AbortStartup { get; set; } [STAThread] public static void Main() { Application.Run(new CancelableSplashScreen()); if (!AbortStartup) Application.Run(new MainWindow()); }
When the splash screen closes, the main window appears if the splash screen does not close the AbortStatup
property to true
. If you added an event handler to Application.ThreadException
from the pop-up screen, the instance of CancelableSplashScreen
will not collect garbage until the application terminates, which may be much later.
source share