如何进行AsParallel()拆分它的'源'?

编程入门 行业动态 更新时间:2024-10-27 03:41:11
本文介绍了如何进行AsParallel()拆分它的'源'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图确定进行AsParallel()是如何拆分它的源,而事实上什么是源...

I'm trying to determine how AsParallel() splits it's 'source', and indeed what is meant by 'source'...

例如意味着..

public class CSVItem { public DateTime Date { get; set; } public string AccountNumber { get; set; } } List<CSVItem> CSVItemList = new List<CSVItem>();

然后把500K不同CSVItem的成CSVItemList。

Then put 500k varying CSVItem's into CSVItemList.

然后使用:

CSVItemList = CSVItemList.AsParallel().OrderBy(x => x.AccountNumber).ThenBy(q => q.Date).ToList();

将它只有'源'(250K记录的意思,例如到每两个线程)分割成多个非同步线程,每个线程上执行的OrderBy()。ThenBy(),然后合并结果...

Will it only split the 'source' (meaning for example 250k records onto each of two threads) onto multiple asynch threads and perform the OrderBy().ThenBy() on each thread then merge the results...

还是会分开的OrderBy()和ThenBy()到单独的线程和运行它们,然后合并结果......给人一种奇怪的有序列表?

Or will it separate the OrderBy() and ThenBy() onto separate threads and run them and then merge the results... giving a strangely ordered list?

推荐答案

据GOSE一个接一个A)与排序依据完成合并的结果,不是为御所B) ThenBy 。下面的图片形式的阿尔巴哈利博客显示它是如何工作的,即它需要一个一个

It gose one by one a) done with OrderBy merge result and than gose for b) ThenBy. Below image form Albahari blog shows how it works i.e. it take one by one

问:有多少数量的任务

答::您可以通过使用决定这 WithDegreeOfParallelism 力量PLINQ同时运行任务指定数量的

A : you can decide this by using WithDegreeOfParallelism forces PLINQ to run the specified number of tasks simultaneously

//create 5 task List.AsParallel().WithDegreeOfParallelism(5)

检查:的并行编程

更多推荐

如何进行AsParallel()拆分它的'源'?

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

发布评论

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

>www.elefans.com

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