Parallel Programming Problems / Overview

I tried replacing some loops with Parallel.For and got some Exceptions, e.g.

Message=This object cannot be modified because it is controlled by a document.
at Rhino.Runtime.CommonObject.ConstPointer()
at Rhino.Geometry.Intersect.Intersection.CurveCurve(Curve curveA, Curve curveB, Double tolerance, Double overlapTolerance)

Both Curves A and B are created locally in the Parallel.For loop.

curveA = (new ObjRef(layers[k].guids[j])).Curve();
curveB = line.ToNurbsCurve();

The tolerances are both RhinoMath.ZeroTolerance.

I guess I shouldn’t use doc in parallel operations, but what about the other stuff? Is there any guide or overview what is thread-safe and what’s not?

Thanks in advance.

Can you provide a little more code? I can’t really figure out what is going on to be able to help.