【问题标题】:AsParallel() method is supported in PCL but not available in .NET Standard 1.3?PCL 支持 AsParallel() 方法,但在 .NET Standard 1.3 中不可用?
【发布时间】:2016-10-23 16:35:39
【问题描述】:

下面的代码在使用 profile7 的 PCL 库中编译时可以正常编译(目标:.NET 4.5、Windows 8、.NET Core 1.0、Xamarin.Android、Xamarin.IOS、Xamarin.IOS Classic)

但是,在将 PCL 项目转换为 .NET Standard 1.3 库后,它会失败并显示:

error CS1061: 'IEnumerable<string>' does not contain a definition for 'AsParallel' and no extension method 'AsParallel' accepting a first argument of type 'IEnumerable<string>' could be found (are you missing a using directive or an assembly reference?)

但是 .NET Standard 1.3 应该仍然支持 PLINQ 的 AsParallel() 方法,对吧? 也许我忽略了什么?是否应该为 PLINQ 包含一个额外的 nuget?

using System.Collections.Generic;
using System.Linq;

namespace PclTest
{
    public class Class1
    {
        public void Test()
        {
          List<string> list = new List<string> { "foo", "bar" };

          var result = list.AsParallel().Where(x => x == "foo").ToList();

          System.Diagnostics.Debug.Assert(result.Count == 1);    
        }
    }
}

我正在使用带有所有最新更新的 Visual Studio 2015

【问题讨论】:

标签: c# .net portable-class-library portability plinq


【解决方案1】:

有一个名为System.Linq.Parallel 的 Nuget 包,它在PCL 中提供了AsParallel 方法

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多