Tweaking Parallel Querying Behavior

Various methods are available in PLINQ to control some aspects of the parallelization of queries. Those methods start with the With prefix and control aspects such as the following:

• Degree of parallelism, specifying how many parallel workers be can running during query execution

• Execution mode, allowing to force parallelism even if PLINQ concludes it’s not worth the effort

• Merge options, controlling query result buffering because the parallel producers and the query consumer can move at their own paces

• Use of a cancellation token, allowing the executing query to be canceled without waiting for all input to be consumed

Because those operations are meant for advanced users who thoroughly understand the ...

Get C# 4.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.