Limit number of Threads in Task Parallel Library

后端 未结 4 1637
悲&欢浪女
悲&欢浪女 2020-12-30 13:27

I have few hundreds of files i need to upload to Azure Blob Storage.
I want to use parallel task library.
But instead of running all the 100 threads to upload in a f

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-30 13:57

    Did you try use MaxDegreeOfParallelism? Like this:

    System.Threading.Tasks.Parallel.Invoke(
    new Tasks.ParallelOptions {MaxDegreeOfParallelism =  5 }, actionsArray)
    

提交回复
热议问题