多线程中的BackgroundWorker类 [英] BackgroundWorker Class in Multithreading

查看:86
本文介绍了多线程中的BackgroundWorker类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我想使用多个CPU计算PI的值,最多100个小数位.如果我有四个CPU,则工作将分配给四个cpu.然后,在这种情况下,第一个CPU将计算最多0到25个小数位的值.第二个CPU同时计算,第2个CPU最多计算小数点后25至50个小数位,第3个CPU同时计算小数位数后最大50至75个小数位,第4个CPU同时计算最大小数点后75至100个小数位.在某种程度上,我想计算并行处理中PI的值.将工作划分为四个不同的CPU的主要思想是,然后使用单个CPU来快速处理输出.

主要逻辑是,如果将单个工作划分为四个cpu,则任何单个CPU将在10秒钟内计算出该工作将很快,并且将在大约4秒钟内完成.

我想使用后台工作者类.



谢谢,
Deepak

Hello,


I want to calculate the value of PI upto 100 decimal places using multiple CPU. If I have four CPU the work is divided among four cpu. Then in that case the first CPU will calculate the value of upto 0 to 25 decimal places. And second CPU simultaneously 2nd CPU will calculate the value upto 25 to 50 decimal places and 3rd CPU will calculate the value upto 50 to 75 decimal places and 4th CPU will calculate upto 75 to 100 decimal places simultaneously. In a way I want to Calculate the value of PI in parallel processing. Main Idea behind the dividing the work in four different CPU is that to process the output fast then using single CPU.

The main logic is that if any single CPU will calculate in 10 sec if that work is divided in four cpu the the work will be fast and it will be completed in approx 4 sec.

I want to use background worker class.



Thanks,
Deepak

推荐答案

我认为.Net 4.0中的TPL是更好的选择.
我想您已经有用于PI的算法了,我发现这很有用. http://www.boyet.com/Articles/PiCalculator.html [为多核计算机优化托管代码 [ ^ ]

任务并行库(TPL)旨在使编写可自动使用多个处理器的托管代码变得更加容易.
I think TPL in .Net 4.0, would be a better option.
I suppose you already have your algorithm for PI in place.I found this one useful. http://www.boyet.com/Articles/PiCalculator.html[^]

You can refere to the following MSDN Magazine article "" Optimize Managed Code For Multi-Core Machines[^]

The Task Parallel Library (TPL) is designed to make it much easier to write managed code that can automatically use multiple processors.


这篇关于多线程中的BackgroundWorker类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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