Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use .AsParallel Extension Method in PCL?

I have a problem in a Portable Class Library class. It seems I cannot use .AsParallel() extension method although System.Linq is referenced. Here is the code:

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

namespace PortableClassLibrary1
{
    public class Class1
    {
        public Class1()
        {
            var list = new List<String>();                
        }
    }
}

list hasn't AsParallel() method, it has only AsQueryable and AsEnumerable.

Target frameworks are .NET 4.5 and highr, Phone 8, Windows Store App (Win 8) and higher. Any ideas?

like image 992
AlexMortola Avatar asked Dec 09 '13 09:12

AlexMortola


1 Answers

The documentation on MSDN lists the method as supported in Portable Class Libraries. Also it is supported in .NET 4 & 4.5 and Windows Store Apps from version 8. The only platform I was not able to find an implementation for is Windows Phone 8.
So I suspect that this is the reason why it is not available in your PCL. I verified this in a test project and as soon as you remove the WP8 platform for the PCL, you can call AsParallel.

like image 110
Markus Avatar answered Nov 10 '22 03:11

Markus