algorithmic modeling for Rhino
Hi all,
We're writing a rhino-plugin to open/run/close a .ghx files in an open instance of rhino/grasshopper. I would like the plugin to get notified if a new item is added in the queue (a mssql database running on the same local machine).
I came up with a solution but i'm looking for a better code pattern since this one has the Rhino+Grasshopper UI locked in the RhinoMainWindow thread. (since rhino is not threadsafe)
Current Solution:
The RhinoPlugin main thread waits for an 'EventWaitHandle' from a seperate thread that gets notified through an SqlDependency. If it receives the event it opens the .ghx file and performs some actions. After it's done it just starts a new SqlDependency. The beauty is that since Rhino is single-threaded you don't run into problems since you just wait. So you can simply stear the rhino/gh instances to do whatever you like.
The downside is the UI is completely locked during the waiting.
Alternative ideas:
- use a windows.forms.timer (single threaded) to poll the database with a normal query every 500ms. This probably won't lock the UI but can be 500ms slower plus the extra query-overload.
- ?
I'm looking forward to any ideas/suggestions/experiences. All thoughts are appreciated!
cheers,
Elco
Tags:
@David,
Hi David, do you have any suggestions to this topic?
thx,
Elco & Jan
Delft
Once you get the event, why not invoke a method on the Rhino main UI thread which starts your Rh+GH logic?
--
David Rutten
david@mcneel.com
Tirol, Austria
Hi David,
Yes i tried that, but i think i invoked on the wrong part or something since GH threw me a very undefined error that it couldn't open a file. I guess it had to do with threading.
Is this the correct way to invoke a method on rhino's main thread?
if(RhinoApp.MainApplicationWindow.InvokeRequired)
{
RhinoApp.MainApplicationWindow.Invoke(MyDelegateMethod);
}
thx,
Elco
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by