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
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