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
"Mike Silver" <(E-Mail Removed)> wrote in message
news:023A80AF-0C2F-4E21-8DCD-(E-Mail Removed)...
>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
|