PLinq vs Parallel.For(each)
As a summary taken from here.
Both approaches work the same way: the initial collection is split up intro smaller chunks (partitions) and the operations are performed on them, in parallel (probably).
Use PLinq when:
- when there is a need of composition, Linq like constructs are easier to reason about
- when order is important
Movies.AsParallel().AsOrdered().Select(…)
Use Parallel.For(each)
- the data is simple in nature and the actions are independent
- when operations need to maintain thread-local state
- when you need to break out of the iteration; this can be done either by calling the Break or Stop methods on the ParallelLoopState class