Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2005

Tip: Looking for answers? Try searching our database.

ThreadAbortException - Why is it rethrown?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vivek - 06 Jul 2005 08:13 GMT
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
-Vivek
Alvin Bruney [MVP - ASP.NET] - 08 Jul 2005 02:35 GMT
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.

Signature

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

> Hi,
>
[quoted text clipped - 4 lines]
> Thanks in advance
> -Vivek
Vivek - 09 Jul 2005 17:25 GMT
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?

> 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
[quoted text clipped - 9 lines]
> > Thanks in advance
> > -Vivek
Alvin Bruney [MVP - ASP.NET] - 09 Jul 2005 19:07 GMT
that's possible as well. i suspect there are more reasons as well.

Signature

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

> Thanks for your views.
> Now that i think more about it I wonder if it has anything to do with
[quoted text clipped - 30 lines]
>> > Thanks in advance
>> > -Vivek

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.