The use of Parallel.For(...)
with side-effects in its body is discouraged. Moreover, even the correct use of synchronization primitives is questionable as it neglects the parallelization gains.
Try to avoid side-effects in general. Make use of the localFinally
argument for aggregation functions and concentrate the side-effects and necessary synchronization in there.