如何同时执行不同的方法?

编程入门 行业动态 更新时间:2024-10-11 17:20:13
本文介绍了如何同时执行不同的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 在我的应用程序中,我使用的是数据集和以下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.

更多推荐

如何同时执行不同的方法?

本文发布于:2023-06-02 00:58:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/430941.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!