Popup while multithreading (rhinocommon): "This action cannot be completed because the other program is busy."

I’d see how Parallel.ForEach fares. It’s for sure the easiest if you are OK with hiding the threading entirely.

It isn’t going to make a difference it the main thread is locked up waiting for all of the other threads to complete. We use the ‘get with timeout’ approach in things like Make2d

I’m not having much luck with multithreading, so I’m thinking I could take another approach, which might actually be better for what I’m trying to do:
have an external program that launches instances of rhino and automatically calls a command to start a simulation, then when finished exits rhino.

How might I do this? Are there any .net projects already set up to do something like this?


External access is done through a process called automation.


Thanks Steve, I’ve got that working (code I copied below), though some issues/questions.

  • I see Rhino come up under background processes in task manager, but it doesn’t disappear after exit is called. How can I make sure Rhino closes?
  • Sometimes the geometry isn’t created. I think this is happening when I don’t end task on the rhino in background processes before opening a new instance. I’m hoping I can run multiple rhino instances, so any thoughts on how to get around this?
  • Is there a way you recommend to send information back to the automation program? I’m thinking I might just generate a text file and then continuously check it…


' Create Application or Interface object On Error Resume Next Dim objRhino = CreateObject("Rhino5x64.Interface") 'Dim objRhino = CreateObject("Rhino5.Application") If (Err.Number <> 0) Then MsgBox("Failed to create Rhino5 object") Exit Sub End If
    ' Make attempts to get RhinoScript.
    ' Sleep between each attempt.
    Dim nCount As Integer
    nCount = 0
    Dim objRhinoScript As Object
    Do While (nCount < 10)
        On Error Resume Next
        objRhinoScript = objRhino.GetScriptObject()
        If Err.Number <> 0 Then
            nCount = nCount + 1
            Exit Do
        End If

    If (objRhinoScript Is Nothing) Then
        MsgBox("Failed to get RhinoScript")
    End If

    Call objRhino.RunScript("_Circle 0 10", 0)
    Call objRhino.RunScript("_Line -5,-5,0 5,5,0", 0)
    Call objRhino.RunScript("_Line 5,-5,0 -5,5,0", 0)
    Call objRhinoScript.Echo("Geometry created.")
    Call objRhino.RunScript("_-Save C:\Users\Sam.lochner\Desktop\test.3dm _enter ", 0)
    Call objRhinoScript.Echo("File saved.")
    Call objRhino.RunScript("_Exit ", 0)
    Call objRhinoScript.Echo("Done!")