码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2014-05-22 16:03:56      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   c   code   java   

bubuko.com,布布扣
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);
    }
});
bubuko.com,布布扣

 

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

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

标签:style   blog   class   c   code   java   

原文地址:http://www.cnblogs.com/zeroone/p/3744035.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!