簡單Parallel.ForEach
不想在圖書館類在類庫使用Parallel.ForEach
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace UtilyTools
{
public class Why
{
public void gluk()
{
var intList= new List<int> { 1, 2, 3};
int notMatter=0;
Parallel.ForEach(list, (item) => notMatter+= item);
}
}
// [...]
給我的老:
CS0103 C# The name
Parallel
does not exist in the current context
Project.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
</PropertyGroup>
</Project>
按照要求屏幕拍攝的錯誤: nb:使用不是以紅色強調。
確切的錯誤是什麼? – Carcigenicate
請注意,這受到併發性問題(在多個線程中變異和讀取相同的變量)。 – Caramiriel
@ Caramiriel,那麼當我翻譯英文錯誤時,錯誤信息中的'Parallel'就會丟失。對不起 –