Plumbing the Depths of the ThreadAbortException Using Rotor
Subject:   Non-aborting exceptions?
Date:   2008-03-31 08:35:02
From:   chaiguy1337
Hi Chris. Great article.

My question concerns the ability for one thread to "invoke" (if you will) an exception on another thread. Is it possible to throw an exception on another thread that does NOT result in that thread aborting?

My situation is thus: I have a thread managing a queue of delegates to execute that get passed in and executed in order. I would like the ability to abort one of these delegates without terminating the entire thread, and my first (I thought) good idea was to do this via ThreadAbortException, handling the exception within the thread loop and essentially ignoring it.

That is, until I read that aborting a thread destroys any hope of using that thread again. So I was wondering if there is a way to cause a thread to throw an exception that would be caught back in my thread loop and processed... without actually aborting the thread.

Furthermore, I just realized this exception would have to not be caught by regular exception handlers, since that would defeat the ability under certain not-uncommon (and unpredictable) circumstances--does ThreadAbortException have this extraordinary ability innately?