Why isn't Parallel.ForEach running multiple threads?

后端 未结 6 2001
离开以前
离开以前 2020-12-15 17:24

Today i tried do some optimization to foreach statement, that works on XDocument.

Before optimization:

foreach (XElement el         


        
6条回答
  •  时光说笑
    2020-12-15 18:06

    Do you happen to have a single processor? TPL may limit the number of threads to one in this case. Same thing may happen if the collection is very small. Try a bigger collection. See this answer for more details on how the degree of parallelism is determined.

提交回复
热议问题