Exception thrown by a thread in a third party library

对着背影说爱祢 提交于 2019-12-24 02:22:59

问题


I am using a third party library in my code. One of the methods on the third party library is getting a thread from the thread pool and doing some work on it. Unfortunately it is throwing an exception from its thread which I am unable to catch and handle because it is from a different thread.

I know that this exception is not going to cause the application any harm (it is not an out of memory exception or anything similar), so I'd like to log it and try the operation again later when it might succeed.

I am currently logging the exception by using the AppDomain UnhandledException event, but my application is still terminating. Is there any way I can catch this exception and handle it?


回答1:


Its really hard to catch exceptions across threads, in fact I think its impossible.

The only work around is to see if they third party library has a call back routine that can notify you of exceptions.

Check the docs/api for the library.



来源:https://stackoverflow.com/questions/12002903/exception-thrown-by-a-thread-in-a-third-party-library

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