static void cd_FormClosing(object sender, FormClosingEventArgs e) { ConnectionDialog cd = (ConnectionDialog)sender; if (cd.DialogResult == DialogResult.OK) { LocalContext.Default.ClientContext = cd.CreateClientContext(); runMainScreen = true; } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #if !DEBUG Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); #endif // Before running main screen, establish connection. ConnectionDialog cd = new ConnectionDialog(); cd.FormClosing += new FormClosingEventHandler(cd_FormClosing); Application.Run(cd); if (runMainScreen) { // Now initialize and run main screen. Application.Run(new MainScreen()); } }