G
Guest
Hello All,
I have an app that I call a Login form in. I have 2 buttons on the login
form. 1 passes back OK and the other Cancel. When I click cancel, I simply
want to catch it in the main app and shut the application down.
My question is, why when you issue Application.Exit() does the program keep
executing lines below it before finally closing the app down? If I put a
'return' under Application.Exit() it exits quickly. If I don't and I trace
it through the debugger it will run through all the code beneath it.
private void Login()
{
frmUserLogin frmLoginObj = new frmUserLogin();
frmLoginObj.FormBorderStyle=FormBorderStyle.FixedToolWindow;
frmLoginObj.Parent = null;
frmLoginObj.ShowInTaskbar = false;
frmLoginObj.TopLevel = true;
frmLoginObj.Visible = false;
/* Show the dialog storing the result. */
DialogResult result = frmLoginObj.ShowDialog();
if (result == DialogResult.Cancel)
{
//this.Close();
Application.Exit();
return; // Return here does the trick, but I shouldn't need it.
}
Other code below here gets ran without the 'return'
I have an app that I call a Login form in. I have 2 buttons on the login
form. 1 passes back OK and the other Cancel. When I click cancel, I simply
want to catch it in the main app and shut the application down.
My question is, why when you issue Application.Exit() does the program keep
executing lines below it before finally closing the app down? If I put a
'return' under Application.Exit() it exits quickly. If I don't and I trace
it through the debugger it will run through all the code beneath it.
private void Login()
{
frmUserLogin frmLoginObj = new frmUserLogin();
frmLoginObj.FormBorderStyle=FormBorderStyle.FixedToolWindow;
frmLoginObj.Parent = null;
frmLoginObj.ShowInTaskbar = false;
frmLoginObj.TopLevel = true;
frmLoginObj.Visible = false;
/* Show the dialog storing the result. */
DialogResult result = frmLoginObj.ShowDialog();
if (result == DialogResult.Cancel)
{
//this.Close();
Application.Exit();
return; // Return here does the trick, but I shouldn't need it.
}
Other code below here gets ran without the 'return'