与动态数据源异步运行数据库密集型应用程序 [英] Asynchronously run a DB intensive application with dynamic data sources

查看:129
本文介绍了与动态数据源异步运行数据库密集型应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我们有一个仪表板应用程序,可以根据从数据库中读取的动态执行的SQL来显示数据.

到目前为止,应用程序已连接到数据库,针对网格(表示数据)循环,读取其SQL源,执行SQL,将结果显示在DataGridViews中,然后转到下一个网格.

很少有快速响应的网格是可以的,但现在我们遇到了这样一种情况,即从用户单击应用程序以打开窗口到实际显示窗口(已满载数据)实际需要2-3分钟.

最初,我认为解决方案是针对此循环的每次运行在后台放置一个"BackgroundWorker",以便在用户启动应用程序后立即弹出窗口,并在网格完全加载后立即显示它们. br/>
棘手的想法是:
1.线程需要运行的代码是动态生成的SQL,在编译时未知,因此无法编写"DoWork()"函数.

2.甚至更多,在编译时网格的数量是未知的,因此无法猜测要使用的有效线程数才能对其进行声明.

关于应该如何从架构上解决这个问题的任何想法?

是"BackGroundWorker"要走的路吗?

预先感谢,
Nick Panoussis

Hi folks,

we have a dashboard application that presents data according to dynamically executed SQL read from a database.

Up to now application connects to the database, loops against the grids (that present data), reads their SQL source, executes the SQL, presents the results in DataGridViews and then goes to next grid.

This is ok with few fast-responding grids but now we ''ve come up to a situation that from the moment that the user clicks the application to open until the window (fully loaded with data) is actually shown takes 2 - 3 mins.

Initially, I thought that solution is to put a "BackgroundWorker", for each run of this loop, in the background so that window pops-up immediately after the user starts the application and grids are presented as soon as they are fully loaded.

The tricky thinks here are:
1. the code that the thread needs to run is a dynamically build SQL which is not known at compile time so no "DoWork()" function can be written.

2. Even more, the number of grids is unknown at compile time so no effective number of threads that need to be used can be guessed in order for them to be declared.

Any ideas on how this should be treated in terms of architecture?

Is the "BackGroundWorker" the way to go?

Thanks in advance,
Nick Panoussis

推荐答案

阅读您的问题时,我想到的第一件事就是多线程. Backgroundworker也正在线程化,但是一次不能有效地拥有多个线程.

创建您自己的线程,然后您可以根据需要动态添加更多线程.创建自己的线程几乎就像Backgroundworkers.尝试在Code Project上查看有关多线程的项目.

我自己创建了将作为线程运行的类,从而设法做到了这一点(多线程处理).我可以控制需要运行的线程数量,也可以作为类来设置可以在运行时设置的属性.
Reading at your question, the first thing that come to my mind is multi-threading. Backgroundworker is threading too but you cannot effectively have more than one threads at a time.

Create your own threads and by doing this you can dynamically add more threads as needed. Creating own threads is almost like Backgroundworkers. Try looking at projects about multi-threading on Code Project.

I managed to do this(multi-threaded process) myself by creating classes that will run as threads. I can control the amount of threads need to be run and also being as classes we can set properties that can be set during running time.


这篇关于与动态数据源异步运行数据库密集型应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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