C# Parallel Loops When Does it Make Sense?

14
2



In this one I show you how to write a parallel.for loop in C# and give you an example of when it make sense to do so. For very simple operations it is typically faster to write a sequential for/foreach loop. This is of course dependent upon CPU architecture among other things but that is not what this video is about. In this one I’m just going over the basics. If you like this topic and are interested in more I can go over Parallel.Invoke, Parallel.ForEach, and maybe do a video on concurrency too.

MSDN Article:

Support the channel by getting your PC gear on Amazon with my affiliate link.
US:

Check out my “Influencer Page”

Nguồn:https://wijstaanvooronzegrondrechten.org/

Xem Thêm Bài Viết Khác:https://wijstaanvooronzegrondrechten.org/cong-nghe

14 COMMENTS

  1. Very helpful. Would like to see the Parallel.ForEach with local variables though. I've been trying to get this to work so I can see subtotals and return a final complete total using a Parallel.Foreach over millions of items.

  2. Thanks for the explain. We are comparing different version of our web services for timing, so are running two versions simultaniously to eliminate side effects from DB access, NEtwrok traffic etc.. I needed to see how this works. Its a lot simpler than I thought!

LEAVE A REPLY

Please enter your comment!
Please enter your name here