Preserving data order and merging data with PLINQ
When fine-tuning PLINQ queries for your applications, there are some extension methods that impact the sequencing of data that you can leverage. Preserving the original order of your items may be something that is required. We have touched on the
AsOrdered method in this chapter, and we will experiment with it in this section. When PLINQ operations have been completed and items are returned as part of the final enumeration, the data is merged from the segments that were created to operate on multiple threads. The merge behavior can be controlled by setting
ParallelMergeOptions with the
WithMergeOptions extension method. We will discuss the behavior of the three available merge options provided.
Let’s get started by creating some samples with the
AsUnordered extension methods.