.NET Detecting Thread exits from external code?
I'm building a library in which to be consumed by a multi-threaded application. And I need a way to determine whether a particular thread is exiting.
Is there a way to add hooks or be notified when a certain Thread
exits if you don't directly owns the thread?
Thread aborts are exceptional and thus I don't care about aborts, only proper exits.
This will greatly simplify the library if it is possible.
Any ideas?
You could start a separate thread of your own and Join()
it to the thread in question.
However, I don't see any simpler way to get an Exited
event.
(Polling IsAlive
is rarely a good option)
精彩评论