我关注这篇文章:
http://blogs.msdn.com/b/csharpfaq/archive/2010/06/01/parallel-programming-in-net-framework-4-getting-started.aspx
在我的控制台应用程序中,可以看到Parallel namespace,但“Parallel.For”编译失败,命名空间“Parallel”中不存在“For”的命名空间类型。
我浏览了一下网络,但除了在System.Threading中没有看到任何东西,System.Threading是我添加的名称空间(尽管它不是程序集引用,在.net framework引用列表中也没有看到)。
以下是我的用法:
using System;
using System.Threading.Tasks;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
违规代码:
Parallel.For(2, 20, (i) => {
var result = SumRootN(i);
Console.WriteLine("root {0} : {1} ", i, result);
});