using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
//aa();
//bb();
//Parallel.For(0, 100, (x) => //结束索引不包含在内
//{
// Console.WriteLine(x);
//});
var list = GetProcuctList();
Parallel.For(0, 100, (x, loopstate) =>
{
if (x < 50)
Console.WriteLine(x);
else
{
loopstate.Break();
return;
}
});
Console.ReadKey();
}
private static void aa()
{
List<int> arrlist = new List<int>();
Enumerable.Range(0, 100)
.AsParallel()
.ForAll((x) =>
{
if (x % 2 == 0 && (x + 1) % 3 == 0)
C#并行计算测试
最新推荐文章于 2024-02-09 15:42:29 发布