O
orekinbck
Hi There
I'm probably missing something fundamental here but I don't understand
the code in the OnThreadException routine, which is found in MSDN under
the topic: Application.ThreadException Event
I think the whole OnThreadException routine could be replaced with two
lines of code:
if (ShowThreadExceptionDialog(t.Exception) == DialogResult.Abort)
Environment.Exit(0);
Why? Because:
(1) FXCop complains about the MSDN example with CA1031 :
Microsoft.Design : Modify ... to catch a more specific exception than
'System.Object' or rethrow the exception.
(2) I don't understand why they even bother catching an exception as
they just give a totally useless message and terminate the application
anyways:
try
{
MessageBox.Show("Fatal Error", "Fatal Error" ...
}
finally
{
Application.Exit();
}
(3) Environment.Exit is more relevant for the project I am working on
as Application.Exit(0) only seems to end the blocking
Application.Run(new myMainForm()) line. If there is code after the
Application.Run line it will still be executed. However I want to give
the application a "bullet in the head".
Thanks In Advance
Bill
I'm probably missing something fundamental here but I don't understand
the code in the OnThreadException routine, which is found in MSDN under
the topic: Application.ThreadException Event
I think the whole OnThreadException routine could be replaced with two
lines of code:
if (ShowThreadExceptionDialog(t.Exception) == DialogResult.Abort)
Environment.Exit(0);
Why? Because:
(1) FXCop complains about the MSDN example with CA1031 :
Microsoft.Design : Modify ... to catch a more specific exception than
'System.Object' or rethrow the exception.
(2) I don't understand why they even bother catching an exception as
they just give a totally useless message and terminate the application
anyways:
try
{
MessageBox.Show("Fatal Error", "Fatal Error" ...
}
finally
{
Application.Exit();
}
(3) Environment.Exit is more relevant for the project I am working on
as Application.Exit(0) only seems to end the blocking
Application.Run(new myMainForm()) line. If there is code after the
Application.Run line it will still be executed. However I want to give
the application a "bullet in the head".
Thanks In Advance
Bill