using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace TaskDemo
{
class Program
{
static void Main(string[] args)
{
ParallelLoopResult result = Parallel.For(0, 10,(int i,ParallelLoopState pls)=>{
Console.WriteLine("{0},task:{1},thread:{2}",i,Task.CurrentId,Thread.CurrentThread.ManagedThreadId);
Thread.Sleep(100);
if (i>7)
{
pls.Break();
}
});
Console.WriteLine(result.IsCompleted);
Console.WriteLine("lowest break iteration:{0}",result.LowestBreakIteration);
Console.Read();
}
}
}