How can I wait till the Parallel.ForEach completes

前端 未结 3 1640
轮回少年
轮回少年 2020-12-15 02:16

I\'m using TPL in my current project and using Parallel.Foreach to spin many threads. The Task class contains Wait() to wait till the task gets completed. Like that, how I c

3条回答
  •  旧时难觅i
    2020-12-15 02:42

    You don't need that with Parallel.Foreach: it only executes the foreach in as many thread as there are processors available, but it returns synchronously.

    More information can be found here

提交回复
热议问题