I tried replacing some loops with Parallel.For
and got some Exceptions, e.g.
Rhino.Runtime.DocumentCollectedException
Message=This object cannot be modified because it is controlled by a document.
Source=RhinoCommon
StackTrace:
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.