调用或致电不止一个方法的更多的同一时间? [英] Invoke or call more than one method at same time?
本文介绍了调用或致电不止一个方法的更多的同一时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何调用在同一时间超过一个以上的方法在asp.net我的网页加载?
我有4种方法在我的网页加载事件来调用。
但我想打电话给所有的4种方法,而不是等待第一个方法来获取完成,然后调用第二个方法。
如何实现这一目标是在asp.net 4.0?
解决方案
任务[] =任务新的Task []
{
新的任务(Method0)
新的任务(方法1)
新的任务(方法2)
新的任务(Method3)
}的foreach(在任务VAR任务)
task.Start();
或者更短。
新建任务(Method0)。开始();
新的任务(方法1)。开始();
新的任务(方法2)。开始();
新的任务(Method3)。开始();
how to call more than one method at same time in my page load in asp.net?? i have 4 methods to called in my page load event. but i want to call all 4 methods and not wait for 1st method to get finish then call 2nd method.
How to achieve this is in asp.net 4.0?
解决方案
Task[] tasks = new Task[]
{
new Task(Method0),
new Task(Method1),
new Task(Method2),
new Task(Method3)
}
foreach(var task in tasks)
task.Start();
Or more shortly
new Task(Method0).Start();
new Task(Method1).Start();
new Task(Method2).Start();
new Task(Method3).Start();
这篇关于调用或致电不止一个方法的更多的同一时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文