// event handlers // Initialize everything on the UI thread soon after the `Application` has been `.Run()`, and transfer context (MainForm) from the SplashForm to the EDDiscoveryForm. private void initTimer_Tick(object sender, EventArgs e) { ((Timer)sender)?.Stop(); ((Timer)sender)?.Dispose(); try { EDDMainForm = new EDDiscoveryForm(); SetLoadingMsg("Checking Ship Systems"); EDDiscoveryController.Initialize(Control.ModifierKeys.HasFlag(Keys.Shift), Control.ModifierKeys.HasFlag(Keys.Control), SetLoadingMsg); EDDMainForm.Init(SetLoadingMsg); // call the init function, which will initialize the eddiscovery form SetLoadingMsg("Establishing Telepresence"); EDDMainForm.Show(); } catch (Exception ex) { // There's so many ways that things could go wrong during init; let's fail for everything! EDDMainForm?.Dispose(); FatalExceptionForm.ShowAndDie(MainForm, "Initializing", Properties.Resources.URLProjectFeedback, ex); } var splashForm = MainForm; MainForm = EDDMainForm; // Switch context splashForm.Close(); // and cleanup }