Breaking parallel loops in .NET C# using the Stop method z

Breaking parallel loops in .NET C# using the Stop method 
z
List<int> integers = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

Parallel.ForEach(integers, (int item, ParallelLoopState state) =>
{
    if (item > 5)
    {
        Console.WriteLine("Higher than 5: {0}, exiting loop.", item);
        state.Stop();
    }
    else
    {
        Console.WriteLine("Less than 5: {0}", item);
    }
});
Breaking parallel loops in .NET C# using the Stop method 
z

 

Breaking parallel loops in .NET C# using the Stop method z,布布扣,bubuko.com

Breaking parallel loops in .NET C# using the Stop method z

上一篇:MVC 全局异常过滤器HandleErrorAttribute


下一篇:roleManager 元素(ASP.NET 设置架构),我是因为SSL弱密码(转)