C# equivalent for VB6 "End"?

  • Thread starter Thread starter Summit
  • Start date Start date
S

Summit

Does anyone know what the C# equivalent for VB6 End is?

I'm starting up a form with a boolean test. If I fail, I just want to
end the app. Even though I close the form, it picks up on the line
after the bracket and continues loading the form.

Here's my snippet:

DalMan._drCurrentUser = DalMan._dtUsers.FindByUserName("Init");
if (DalMan._drCurrentUser == null)
{
MessageBox.Show("Unable to initialize. Please contact your
administrator.","Initialization
Error",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Stop);
SplashScreen.CloseForm();
this.Close();
this.Dispose();



}
 
Hi Summit,

If you put the check in Main() you can just return; before doing Application.Run
 
Summit,

As it should. What I would do is make a call to the static Exit method
on the Application class, and then return from the method immediately. You
have to unwind the stack up to the point where the message handler processed
the message using this method, so if you return from a method, you have to
make sure that all methods return without executing any more code as well.

Hope this helps.
 
Hi Summit,

If you put the check in Main() you can just return; before doing Application.Run
 
Back
Top