I'm refactoring code that was written some time ago when linq and delegates didn't exist and a lot of the code is embarrassingly parallelizable so I'm using
AsParallel whenever I can but I'm not quite sure what happens when ordered lists are involved in such queries. For example,
/* suppose we have the following list SortedList<DateTime, SomeClass> list1 */ var projection = list1.AsParallel().Select(t => t.Key); var skippedProjection = list1.AsParallel().Select(t => t.Key).Skip(1); var zipped = projection.AsParallel().Zip(skippedProjection, someComputation);
My question is the following: Is the ordering preserved in parallel queries? In other words will the above example work as I expect or will the
Select queries following
AsParallel return things in random order depending on what strategy is used behind the scenes?