2

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?

4

1 回答 1

2

跨线程捕获异常真的很难,事实上我认为这是不可能的。

唯一的解决方法是查看他们的第三方库是否有一个可以通知您异常的回调例程。

检查库的 docs/api。

于 2012-08-17T09:10:43.243 回答