开发者

.NET Detecting Thread exits from external code?

开发者 https://www.devze.com 2023-03-08 17:55 出处:网络
开发者_运维问答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.
开发者_运维问答

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号