I can't seem to wrap my head around what the difference is between AsSequential and AsOrdered. I have looked up documentation on msdn for each of these as well as searching the internet for examples, but I am just a simple shoe cobbler and I was unable to definitively understand what is going on. If possible, could someone please explain when you would use AsSequential vs AsOrdered, and if necessary explain how the results would be different?
In PLINQ, what is the difference between .AsSequential() and .AsOrdered()?
AsOrdered
instructs the Parallel LINQ engine to preserve ordering, but still executes the query in parallel. This has the effect of hindering performance as the engine must carefully merge the results after parallel execution.
AsSequential
instructs the Parallel LINQ engine to execute the query sequentially, that is, not in parallel.
Thank you for the reply. So the AsSequential is overriding the AsParallel? What type of use case would there be for AsSequential? Is it for an unevaluated enumerable to prevent it from being run AsParallel? –
Corbeil
When you have a very complex query, you can specify to use parallism in general. And in some parts of the query, you can choose to execute sequentially (with AsSequential) –
Guyon
@Guyon can you give an example? –
Galcha
The doc says this: "This example shows how to use the AsSequential method to instruct PLINQ to process all subsequent operators in the query sequentially." learn.microsoft.com/en-us/dotnet/standard/parallel-programming/… –
Osmund
© 2022 - 2024 — McMap. All rights reserved.