views:

39

answers:

1

I am following 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 app Parallel namespace is visible, but "Parallel.For" fails compilation with "type of namespace For does not exist in namespace 'Parallel'".

I've scoured the net, but not seeing anything other than it is in System.Threading which is a namespace i've added (although it is not an assembly reference, and i don't see it in .Net framework references list).

using vs2010 project is using framework 4.0.

here are my usings:

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

offending code:

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

After a closer look at your error message i think that maybe you are using "Parallel" as the name/namespace for your project?

In case of doubt you can use System.Threading.Tasks.Parallel.For(...)

Henk Holterman
also added.....
Sonic Soul
@Sonic, see edit.
Henk Holterman