0

Why this first code works

MessageBox.Show("No Applicants\nFirst Add applicants with dataentryaccount");
MainWindow mw = new MainWindow();
mw.Show();
this.Close();

But this second code doesn't show the mw window

    MessageBox.Show("No Applicants\nFirst Add applicants with dataentryaccount");
MainWindow mw = new MainWindow();
this.Close();
mw.Show();

Although when debugged Line by Line all these lines are executed.

1 Answers1

1

The EventHandler or procedure of the current execution block has some more code to execute.
You have not called return to stop the execution of the current procedure.

Close() is just another function which will not delete the form immediately. So it continues the execution of the current code.

Please check this answer for more details.

Community
  • 1
  • 1
Olivarsham
  • 1,701
  • 5
  • 25
  • 51