如何同时执行不同的方法? [英] How can I execute different methods at the same time?

查看:83
本文介绍了如何同时执行不同的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在我的应用程序中,我使用的是数据集和以下4种方法.

Hi All,

In my application I am using a dataset and 4 methods like below.

Dataset ds=new Dataset();
ds=businesslogiclayerObject.method1(a,b,c,d);
ds=businesslogiclayerObject.method2(a,b,c,d,e);
ds=businesslogiclayerObject.method3(a,b,c,d,e,f);
ds=businesslogiclayerObject.method4(a,b,c,d,e,f,g,h);



Businee逻辑层:



Businee logic layer:

public Dataset method1(int a,string b...string d);
{
//used hash table object  to send parameternames and storedprocedure to DataAccess Layer.

}


其余3种方法的语法也相同.

(a,b,c,d,e,f,g,h)是Businesslogic层中存储过程的参数.到现在为止我还没有实现任何线程概念,因此它们是一个接一个地执行.这需要大量时间才能在Dataset中获得结果集.

如何同时执行上述4种方法?

帮帮我.

问候,
N.SRIRAM


same syntax for remaining 3 methods also.

(a,b,c,d,e,f,g,h) are the parameters to Stored Procedure in Businesslogic Layer. Till now I did not implement any threading concept so they are executing one by one.This takes lot of time to get result set in Dataset.

How can I execute above 4 methods at the same time?

Help me.

Regards,
N.SRIRAM

推荐答案

请记住您的代码是ASP.NET,因此一旦页面完成呈现,它将返回给用户,而不会等待您的其他线程完成.正如其他人所说,您可以使他们成为一个SP来节省时间,如果效率低下,您还可以加快SQL的速度;如果这是问题的话,或者如果您不这样做,则可以改善数据库的设计请注意是否在完成工作之前返回页面,将这项工作分配给可以在不降低页面速度的情况下进行的服务.
Remember that your code is ASP.NET, so once your page finishes rendering, it will return to the user and it will not wait for your other threads to finish. As someone else said, you can make them one SP to cut time, you can also look to speed up your SQL if it''s inefficient, improve your DB design if that''s the issue, or if you don''t care if the page goes back before the work is done, farm this work off to a service that does it without slowing your pages down.


除了其他人所说的:

看来您正在使用相同的参数进行构建.

In addition to what others said:

It appears that you are building using the same parameters.

ds=businesslogiclayerObject.method1(a,b,c,d);
ds=businesslogiclayerObject.method2(a,b,c,d,e);
ds=businesslogiclayerObject.method3(a,b,c,d,e,f);
ds=businesslogiclayerObject.method4(a,b,c,d,e,f,g,h);



您的参数从a,b,c,d增长到a,b,c,d,e,f,g,h.好,第一个是最后一个的子集.不用看代码就很难分辨出来,但是您在所有方法上都有代表代码吗?您可以重构代码,以便更少的方法可以为您完成工作吗?可能所有您需要的是最后一种方法,然后重构工作?但是又很难不看代码就很难分辨.



your parameter is growing from a,b,c,d to a,b,c,d,e,f,g,h. well the first is a subset of the last. It is very hard to tell with out looking at the code, but do you have repreatitive code on all the methods? Can you re-factore the code, such that, fewer methods can do the work for you? may be all what you need is the last method and then refactor the work? But again very hard to tell without seeing the code.


您可以使用DataReader代替DataSet.
You can use DataReader instead of DataSet.


这篇关于如何同时执行不同的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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