标签:完成 reac task service eof for bsp 并发 foreach
1.主线程参与计算
1 //用Task完成这个 你们会吗 不在意那个主线程参与计算的事儿 2 //Parallel.Invoke(() => this.Coding("爱书客", "Client") 3 // , () => this.Coding("风动寂野", "Portal") 4 // , () => this.Coding("笑看风云", "Service"));
2.2个api
1 { 2 Parallel.For(0, 5, i => this.Coding("爱书客", "Client" + i)); 3 } 4 { 5 //Parallel.ForEach(new string[] { "0","1","2","3","4"}, i => this.Coding("爱书客", "Client" + i)); 6 }
3.可以控制并发数量
1 { 2 ////parallelOptions 可以控制并发数量 3 //ParallelOptions parallelOptions = new ParallelOptions(); 4 //parallelOptions.MaxDegreeOfParallelism = 3; 5 //Parallel.For(0, 10, parallelOptions, i => this.Coding("爱书客", "Client" + i)); 6 }
标签:完成 reac task service eof for bsp 并发 foreach
原文地址:https://www.cnblogs.com/Spinoza/p/10989451.html