I have 2 forms (main and login). I open the login form with this piece of code:
toolStripProgressBar1.Value = 50;
toolStripStatusLabel_dynamic.Text = "Proberen toegang te verkrijgen...";
Login login = new Login();
login.ShowDialog();
do_login();
And I have a toolstrip menu at the top of the login form with an eventhandler like this:
private void afsluitenToolStripMenuItem_Click(object sender, EventArgs e) {
Application.Exit();
}
But after both forms are closed, the program continues to work (it calls the function do_login.) But the variables aren’t set, and the form is gone, so do_login won’t work at all…
So how will I make the whole execution of the program stop when I click the toolstrip?
You’re going to have to work around it because the definition of
Application.Exit()is as follows.So what it’s saying is once all messages have been fully processed it will exit, but since you have a message that needs processed after the dialog closes it has to finish that first. You are doing the exit properly, but you’re going to have to check for
nulland return if it isnullin thedo_Login()method.