如何在C#中使用多任务和多线程? [英] How to use multi tasking and multi threaded in C#?
本文介绍了如何在C#中使用多任务和多线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尊敬的先生,
如何使用多任务和多线程:
我的任务是:
1.客户在网页上订购了商品,
2.这些订单项在队列中像一个接一个地等待,(同一时间100个订单)
3.如何在这种情况下应用多任务概念,
4.请为此做个准备?
在此先感谢
通过Mohan.
Dear sir,
How to use multi-tasking and multi-threaded :
My Task is:
1. Customer''s ordered the item in web page,
2. These order items are waiting in Queue like one by one,(same time 100-Orders ordering)
3. How to apply multi-tasking concepts this situation,
4. Please give the way for this?
Thanks in Advance
By Mohan.
推荐答案
您可以使用Parallel.ForEach()
有了它,您可以添加代码以从队列中提取代码,从而提高性能并进行多任务处理.如果使用mutli-CPU,
You can use Parallel.ForEach()
With this you can add code to fetch from queue, it increase performance and there will be multi-tasking, It also provide greater results if using mutli-CPU
这篇关于如何在C#中使用多任务和多线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文