application.exit, application.exitthread exit application problem

G

Guest

I have a windows form application. It is accessing a backend SQL server. The
data access are wrapped in modules. If the data access failed, I wanted to
display a popup error message and then exit the application. I tried to use
Application.Exit(), Application.ExitThread, and Environment.Exit(). They all
have kind weird problem.
1. Applicaiton.Exit() This method is called within an exception block, after
displaying a message box to the user. It seems it is not doing anything. The
rest of code will be executed in order like nothing happened.

2. Application.ExitThread() The same as Application.Exit()

3. Thread.CurrentThread.Abort() This method will cause ThreadAbort
Exception, so I have to handle this exception from layer to layer.

4. Environment.Exit() In exception catch block, I display the message box,
and then call this method. This caused the application to exit, but the
message box just flashed and disappeared.

Thanks!

John
 
B

Brian Hammer

I ran into something similar and had to remove the exit to another sub:


Private Sub SomeSub()
try
'do the work and an error happens
catch er as exception
ExitErrorApp
exit sub
end try
End sub

private sub ExitErrorApp()
application.exit
end sub



I thin I had to do this in my sub main because I was checking for an
instance of the same app. If it was running, I closed the current.

HTH,
Brian
 

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