Exiting program

G

Guest

Hi folks,

I have a simple form like this:

public class Blah: System.Windows.Forms.Form{
private OleDBConnection conn;
public class Blah(){
conn.ConnectionString = "... ....";
try{
conn.open();
}
catch(Exception e){
Application.Exit(); <--- does not work
}
}

static void Main(){
Application.run(new Blar());
}
}

Problem:
1. When system fails to connection to SQL server, it catchs error and
executes Application.Exit(). But it does not work! After this line, it still
pops up the form.

Question:
1. How to terminate program properly when something goes wrong during system
loading?

Thanks,

Karl
 
G

Guest

Calling Application.Exit only sends a message that it wants to shutdown, but
you must exit the procedure before it will actually shutdown. Just type
return; so that it exits the procedure after the Application.Exit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top