Undo Enumerable.AsParallel(), going back to serial mode

Viewed 138

Assume you have a LINQ query like

source.AsParallel().Where(expensiveOperation).Select(cheapOperation)

I suppose in this case Select also runs in parallel execution mode. Maybe it's just a cheap operation like i => i*2, so is there a way to stop parallel execution at a point of querying with chained methods?

(maybe like .AsParallel().Where(expensiveOp).AsSerial?().Select(cheapOp)?)

1 Answers
Related