Using "RhinoDoc doc" as argument of a function using a

Need help

I’m trying to do the following .

1- I wrote a dummy method using “RhinoDoc doc” as a parameter.

Here is the code:

public static void test(RhinoDoc doc)
{
RhinoApp.WriteLine(“Thread1”);
}

2-Then I created a separate thread in the plugin to run the method in parallel, but nothing happen ( no error … but no result! ).

Here is the code:

using System.Threading;
…
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{

Thread thread1 = new Thread(()=>Process.test(doc));
thread1.Start();

Can you Help?

Hi @Johnny_Boivin,

For what it’s worth, the Rhino document is not thread safe.

What are you trying to do and why?

– Dale

Thanks for your fast response. I’m working on a naval architecture plugin where I have to make 37 copies of a base hull and rotate them by increment of 5 degree to calculate the portion of the hull that will be underwater at different heeling degrees( from 0 to 180 degree = 37 cases ) I already wrote the plugin without using multithreading and it works perfectly well but its a little slow. So for example ,instead on running one big loop like for(int hullIdx=0;hullIdx<38;hullIdx++) {RunStudy[hullIdx, doc ]}. I thought that i can split it into smaller loop and run it on different threads. This is what I’m trying to do .

Hello Dale, I found a solution. The threading code should not reside in the “protected override Result RunCommand(RhinoDoc doc, RunMode mode)” of the XCommand class but should happen in a method residing in another class outside the plugin