Best way to retrigger 'SolveInstance'


#1

Hello,

I’m trying to create my own UDP receiver (similar to gHowl), but I’m having trouble with one thing. I’m able to receive the signals correctly, however the only way I can think to get continuous input is in a loop. An infinite loop locks up the plugin, so I tried calling solve instance after I receive the info, however this also locks up the program.

Is there a safe way to call solve instance again and allow it to finish? If I have an input slider and drag it, solve instance gets called again appropriately, but is there a way to simulate this via code?


(David Rutten) #2

It’s somewhat complicated if your events are coming in on a non-UI thread, but in either case the best way to trigger continuous updates is to use GH_Document.ScheduleSolution(delay, callback).

Pick a non-zero delay (say 5 or 10 milliseconds) and supply a callback method. The method will be invoked before the scheduled solution actually starts, and it is a great place to expire the relevant components/parameters. Just be sure to use ExpireSolution(false) and not ExpireSolution(true), because a new solution is already happening.


#3

I’m having trouble expiring the solution, because I’m not calling it from the same thread. I’ve seen alot of talk online with this sort of error, so I need to do some more research


#4

“Control ‘GH_DocumentEditor’ accessed from a thread other than the thread it was created on.”


(David Rutten) #5

Yup, don’t access UI controls from threads, call the ScheduleSolution method on GH_Document.