private void frmMain_FormClosed(object sender, FormClosedEventArgs e) { Thread.Sleep(500); if (this.frm != null) { if (!this.frm.IsDisposed) { this.frm.Dispose(); } this.frm = null; } GC.Collect(); Application.Exit(); }
private void bgwLoading_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { try { if (this._loginResult == frmLogIn.LoginResult.InvalidVersion) { DialogResult dialogResult = MessageBox.Show(this._loginResultMessage, "", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); if (dialogResult == DialogResult.Yes) { Process.Start(ApplicationInfo.WebService.GetUrlClient()); } if (this.splashForm != null) { this.splashForm.Close(); } this.txtPassword.Enabled = true; this.btnLogin.Enabled = true; return; } if (this._loginResult == frmLogIn.LoginResult.Fail) { if (this.splashForm != null) { this.splashForm.Close(); } if (this._loginResultMessage != string.Empty) { MessageBox.Show(this._loginResultMessage); } else { MessageBox.Show("Unknow error!!!"); } this.txtPassword.Enabled = true; this.btnLogin.Enabled = true; this.txtUserID.Focus(); this.txtUserID.SelectAll(); return; } if (this.splashForm != null) { this.splashForm.Close(); } this.txtUserID.Text = string.Empty; this.txtPassword.Text = string.Empty; this.txtPassword.Enabled = true; this.btnLogin.Enabled = true; this.txtUserID.Focus(); this.txtUserID.SelectAll(); this.chkSettingProxy.Checked = false; } catch (Exception ex) { this.ShowError("bgwLoading_RunWorkerCompleted", ex); } base.Hide(); try { if (this.frm == null) { this.frm = new frmMain(); } this.frm.FormClosed -= new FormClosedEventHandler(this.frmMain_FormClosed); this.frm.FormClosed += new FormClosedEventHandler(this.frmMain_FormClosed); this.frm.Show(); if (this.splashForm != null) { this.splashForm.Close(); this.splashForm.Dispose(); } this.splashForm = null; } catch (Exception ex) { EventLog.WriteEntry("i2Trade", ex.Message, EventLogEntryType.Error); } }