CancellationTokenSource cts = new CancellationTokenSource(); ParallelOptions pOptions = new ParallelOptions() { CancellationToken = cts.Token }; pOptions.MaxDegreeOfParallelism = 3;//设置并发线程数量 Parallel.For(0, 100, pOptions, i => { });
CancellationTokenSource cts = new CancellationTokenSource(); ParallelOptions pOptions = new ParallelOptions() { CancellationToken = cts.Token }; pOptions.MaxDegreeOfParallelism = 3;//设置并发线程数量 Parallel.For(0, 100, pOptions, i => { });
原文:https://www.cnblogs.com/by-lhc/p/8287372.html