public BPServer(ApplicationContext AppContext) { //TODO: either use AppContext or remove it // https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.application.run //this.appcontext = AppContext; dicomserverconfig = new DicomServerConfiguration(); powerpathloginconfig = new PowerPathConfiguration(); pploginform = new PPLoginForm(powerpathloginconfig); pploginform.Closing += new System.ComponentModel.CancelEventHandler(this.pploginform_Closing); //note: Application.Run(pploginform) terminates when the form disposes pploginform.Show(); Application.Run(AppContext); }
/// <summary> /// Start the BPServer AFTER the PowerPath Db Form closes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pploginform_Closing(object sender, System.ComponentModel.CancelEventArgs e) { PPLoginForm ppform = (PPLoginForm)sender; powerpathloginconfig = ppform.ServerLogin.Copy(); if (false == powerpathloginconfig.ValidDbConnection) { Log.Fatal("Failed to get a valid connection to PowerPath."); MessageBox.Show("Failed to get a valid connection to PowerPath.\r\nModality Worklist (MWL) is unavailable!"); Environment.Exit(0); return; } else { Log.Debug("Valid valid connection to PowerPath, stating MWL server."); //drop messaging from form thread? //this.appContext.ExitThread(); } this.RunServer(); }