引用线程中的数据集 [英] reference datasets in threads

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

问题描述



我写了一个Windows服务,其中包含不同的类,每个类包含2-3个线程.每个线程具有不同的功能.每个线程与数据库通信.有时,总应用中的线程数可能会增加到20-30,在此服务中,我使用了引用的数据集.

问题是:经常有一些数据集引用另一个数据集,而在获取记录时又引发了异常(列"xxx"不属于该表)并且线程停止.

请让我知道解决方案,或者编程方法中的任何错误.

谢谢.
问候
Murty

Hi,

I have written a windows service, which contains different classes, each class contains 2-3 threads. Each thread has different functionality.each thread comminicating with the database. sometimes no.of thread in the total applciation may increase upto 20-30, in this service i have used referenced datasets.

The problem is : frequently some datasets refers the another dataset, while fetchs the records then it raises the exception, (Column ''xxx'' doesnot belongs to this table) and thread stops.

Please let me know the solution, or any wrong in the programming methodology.

Thanks inadvance.
Regards
Murty

推荐答案

这就是它,在错误消息中有明确说明.它与线程无关.只需检查一下您的查询即可.

至于编程方法,我没有发现任何问题,但是使用了许多线程,尤其是在运行时定义的线程数量无法预测的情况下,这对我来说是个问题.它总是更好,在大多数情况下,可以有固定数量的线程,或者在进程生命周期的早期确定多个线程.

另一个值得怀疑的事情是线程由于异常而终止.通常,您应该在每个线程的堆栈的顶部捕获所有异常.有时,您应该在每个线程的最外层工作周期中捕获所有异常(如果存在).

在不知道设计细节的情况下很难准确地说.

—SA
This is what it is, clearly explained in the error message. It has nothing to do with threads; just check up your queries.

As to the programming methodology, I see nothing wrong, but using many threads and especially if there is unpredictable number of threads defined by the runtime — it looks questionable to me. It''s always better and in most cases possible to have fixed number of threads, or to have a number of threads determined early in the process''s life time.

Another questionable thing is the thread terminated due to exception. Normally, you should catch all exceptions on the very top of the stack of every thread; sometimes, you should catch all exceptions on the very outer working cycle of each thread, if such thing exists.

Hard to say more exactly without knowing fine detail of your design.

—SA


这篇关于引用线程中的数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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