Any special link needed for C # 4.0 Parallel.For?

I follow this article: http://blogs.msdn.com/b/csharpfaq/archive/2010/06/01/parallel-programming-in-net-framework-4-getting-started.aspx

and in my console application I see a parallel namespace, but "Parallel.For" compilation failure with the "namespace type For" does not exist in the namespace "Parallel".

I browsed the net but can’t see anything except in System.Threading, which is the namespace I added (although this is not a link to the assembly, and I don’t see it in the .Net framework list of links).

using the vs2010 project, it uses framework 4.0.

here are my posts:

using System; using System.Threading.Tasks; using System.Threading; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; 

violation code:

  Parallel.For(2, 20, (i) => { var result = SumRootN(i); Console.WriteLine("root {0} : {1} ", i, result); }); 
+4
source share
1 answer
  System.Threading.Tasks 

After taking a closer look at your error message, I think you are probably using "Parallel" as the name / namespace for your project?

If in doubt, you can use System.Threading.Tasks.Parallel.For(...)

+4
source

All Articles