Using ThreadExceptionEventHandler: determine which thread caused the exception

情到浓时终转凉″ 提交于 2019-12-24 03:07:24

问题


Using the Application.ThreadExceptionEventHandler, is it possible to determine which thread caused the exception (the thread id)?

The same question applies to using the AppDomain.UnhandledExceptionEventHandler to catch non-UI thread exceptions.

If the answer is no, is there any other way to determine which thread raised the unhandled exception in such cases?


回答1:


I haven't checked, but I'd expect the handler to be executed in the thread which threw the exception - in which case Thread.CurrentThread would be what you want. I can't see how it would make much sense for the handler to be executed in any other thread.



来源:https://stackoverflow.com/questions/1301153/using-threadexceptioneventhandler-determine-which-thread-caused-the-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!