Groups | Blog | Home
all groups > dotnet academic > july 2005 >

dotnet academic : ThreadAbortException - Why is it rethrown?


Vivek
7/6/2005 12:13:02 AM
Hi,

I have a question regarding ThreadAbortException. Why is the thread abort
exception rethrown at the end of a catch clause?
Why is ThreadAbortException's behavior designed to be this way?

Thanks in advance
Alvin Bruney [MVP - ASP.NET]
7/7/2005 9:38:03 PM
Not sure but I believe it has to do with caller notification. If the thread
aborted, the caller couldn't possibly know what killed the thread. An
automatic rethrow allows the caller to know, since the caller isn't
necessarily the one inducing the thread abort.

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
[quoted text, click to view]

Vivek
7/9/2005 9:25:02 AM
Thanks for your views.
Now that i think more about it I wonder if it has anything to do with giving
functions upper in the call stack a chance to free unmanaged resourecs on
their call stack if any!
Example
foo1 is a method that the thread is executing (basically foo1 is the
ThreadStart parameter)
foo1 calls foo2 . foo2 opens some files (unmanaged calls) and then calls foo3
Assume we call the Abort method while foo3 is executing
If execution concluded in the ThreadAbortException of foo3 the files would
still be open!

Maybe that's the reason by ThreadAbortException is always rethrown unless
ResetAbort is explicitly called?

Any thoughts?

[quoted text, click to view]
Alvin Bruney [MVP - ASP.NET]
7/9/2005 2:07:37 PM
that's possible as well. i suspect there are more reasons as well.

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
[quoted text, click to view]

AddThis Social Bookmark Button