If you abort one managed thread from a开发者_开发技巧nother, using Thread.Abort, how does the CLR actually throw the exception on the other thread? Seems like a neat trick!
I've found a few interesting links on the subject. ThreadAbortException is a special case, and it is handled specially by the CLR.
http://mnikoo.net/2007/02/07/the-magic-of-the-clr-threadabortexception/
http://blogs.msdn.com/b/clrteam/archive/2009/04/28/threadabortexception.aspx
I wrote a blog post on this awhile back. The first part is about when a thread can be aborted, the second is about how it actually works.
I hadn't ever seen any correct (in this case, complete) documentation about how it actually works, so I wrote about about it.
The jist is that the CLR will use SetThreadContext (a win32 api) to hijack your current IP and move you into a special stub to set up the thread abort if you're thread isn't in an abortable wait.
Check out the post here
精彩评论