Parallel.For(0, 100, new ParallelOptions() { MaxDegreeOfParallelism = 100 },(i, pls) => { if (i > 30) { pls.Break();//相当于continue return; } });
Parallel.For(0, 100,new ParallelOptions() { MaxDegreeOfParallelism = 100 }, (i, pls) => { if (i > 30) { pls.Stop();//相当于break return; } });
Parallel.ForEach(collection, new ParallelOptions { MaxDegreeOfParallelism = 10 }, (item, pls) => { });