第三方库中的线程引发的异常 [英] Exception thrown by a thread in a third party library

查看:75
本文介绍了第三方库中的线程引发的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在代码中使用了第三方库。第三方库上的方法之一是从线程池中获取线程并对其进行一些工作。不幸的是,它从其线程中引发了一个异常,我无法捕获并处理该异常,因为它来自其他线程。



我知道该异常不会导致对应用程序有任何危害(不是内存不足异常或类似的东西),因此我想对其进行记录,并在以后可能成功时再次尝试操作。



<我当前正在使用AppDomain UnhandledException事件记录该异常,但我的应用程序仍在终止。

解决方案

在整个线程中捕获异常确实很困难,实际上我



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



检查库的docs / api。


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?

解决方案

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.

这篇关于第三方库中的线程引发的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆