| title | ms.custom | ms.date | ms.prod | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | manager | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
How to: Specify Merge Options in PLINQ |
03/30/2017 |
.net |
dotnet-standard |
article |
|
0f33b527-e91a-4550-a39a-e63e396fd831 |
11 |
rpetrusha |
ronpet |
wpickett |
How to: Specify Merge Options in PLINQ
This example shows how to specify the merge options that will apply to all subsequent operators in a PLINQ query. You do not have to set merge options explicitly, but doing so may improve performance. For more information about merge options, see Merge Options in PLINQ.
[!WARNING] This example is intended to demonstrate usage, and might not run faster than the equivalent sequential LINQ to Objects query. For more information about speedup, see Understanding Speedup in PLINQ.
Example
The following example demonstrates the behavior of merge options in a basic scenario that has an unordered source and applies an expensive function to every element.
[!code-csharpPLINQ#23] [!code-vbPLINQ#23]
In cases where the xref:System.Linq.ParallelMergeOptions.AutoBuffered option incurs an undesirable latency before the first element is yielded, try the xref:System.Linq.ParallelMergeOptions.NotBuffered option to yield result elements faster and more smoothly.
See Also
xref:System.Linq.ParallelMergeOptions
Parallel LINQ (PLINQ)