本文介绍了任务并行库 - 并行的单核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个WPF应用程序。
在屏幕/视图我不得不作出6调用WCF服务。没有这些电话都与在他们不共享数据也不是他们互相依赖的感觉。我打算使用第三方物流,使这6 WCF服务电话为6的任务。现在,应用程序可能会被部署单核机或多核机器上。

I am working on a WPF application.
In a screen/View i have to make 6 calls to a WCF service. None of those calls are related in the sense they dont share data neither are they dependent on each other. I am planning to use TPL and make these 6 WCF service calls as 6 tasks. Now the application might be either deployed on a single core machine or multiple core machine.

我被告知,TPL对单核机的使用实际上会增加时间采取的任务,因为这将被放置在CPU调度时间剪接不同任务的开销完成。这是真的。如果是的话,我应该还是继续我的设计或者我应该看的替代品。

I am being told that usage of TPL on single core machine would actually increase the time take for the tasks to complete because of the overhead that would be placed on the cpu scheduler to time splice different tasks. Is this true. If yes should i still continue with my design or should i look at alternatives.

如果我必须看的替代品,什么是这些替代品:)?

if i have to look at alternatives, what are those alternatives :) ?

推荐答案

在做什么CPU密集型的,你会用单核机器上运行的并行线程加入的开销。

When doing something CPU intensive, you would be adding overhead by running parallel threads on a single core machine.

在你的情况的任务不是CPU密集型的,他们都在等待一个服务调用响应,这样就可以很好的单核机器上运行的并行线程。

In your case the tasks are not CPU intensive, they are waiting for a service call to respond, so you can very well run parallel threads on a single core machine.

根据服务器如何处理来电,有可能没有任何时间而增加呢。如果呼叫排队的服务器上,这将需要大约相同的时间,反正运行的所有呼叫。在这种情况下,它会更好,运行序列中的电话,只是因为它的简单。

Depending on how the server handles the calls, there might not be any time increase anyway. If the calls are queued on the server, it will take about the same time to run all calls anyway. In that case it would be better to run the calls in sequence, just because it's simpler.

这篇关于任务并行库 - 并行的单核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 09:39