我试图确定进行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()拆分它的'源'?
发布评论