DEV Community


Discussion on: C#, Task.WhenAll vs Parallel.ForEach

garryxiao profile image
Garry Xiao Author

Hi Alexandis, in the production environment, there are three points I would mention:

  1. Resource limitation. So after you read the list, if you want to use a different thread for each item, you need to know how many items there and inside the thread, how many images may have and the processing would have.
  2. If you make a new thread other than the main thread, async makes no sense. Maybe I am wrong.
  3. In multiple threads, fewer relations more benefits, pay attention to the lock issue.