Starting a new thread in a foreach loop

后端 未结 5 971
你的背包
你的背包 2020-12-05 10:24

I have a List of objects and I\'d like to loop over that list and start a new thread, passing in the current object.

I\'ve written an example of what I thought shoul

5条回答
  •  温柔的废话
    2020-12-05 10:58

    Agree with Reed's answer (+1).

    I would add that if you are on .NET 4, you may want to look at the Task Parallel Library to solve this class of problem. Specifically for this case, have a look at Parallel.ForEach().

提交回复
热议问题