i have an extension method for IEnumerable which then iterates through the collection, doing its business, and then returns an new IEnumerable.
I have tried to use PLINQ using .AsParallel().ForAll() which speeds up the iterations significantly (which of course it should do) however when the collection is returned, there are often a few objects in that collection that are null.
I'm assuming this may be because it is returning the collection before all the 'business' has a chance to complete? if i debug and put in a breakpoint, there are no nulls.
is there some sort of 'wait for this operation to be completed' method that i should be using?
EDIT: to be a bit clearer, there is business logic in the forall, modifying properties etc. it's necessary to have an action looped, rather than simply selecting something.