PLINQ delayed execution
- by tbischel
I'm trying to understand how parallelism might work using PLINQ, given delayed execution. Here is a simple example.
string[] words = { "believe", "receipt", "relief", "field" };
bool result = words.AsParallel().Any(w => w.Contains("ei"));
With LINQ, I would expect the execution to reach the "receipt" value and return true, without executing the query for rest of the values.
If we do this in parallel, the evaluation of "relief" may have began before the result of "receipt" has returned. But once the query knows that "receipt" will cause a true result, will the other threads yield immediately?
In my case, this is important because the "any" test may be very expensive, and I would want to free up the processors for execution of other tasks.