How to use an external event to trigger the update the outputs of a component?

unhandled

#1

Hi,
I’m working on a component to read data from a 3d camera and would like my component to output every available frame. I have a listener that gets called when a new frame is available and I have the data available in the SolveInstance method, but how do I trigger the reevaluation every time a new frame becomes available?

I tried to call ExpireSolution from the listener but that did not help.

What would be the correct way?

cu
Flo


(David Rutten) #2

ExpireSolution(true) should work, just be sure to include the true argument. Also, do not call that method from a thread other than the UI thread.


#3

Hi David,
thank you very much for you reply.

Also, do not call that method from a thread other than the UI thread.

Ah, so I guess that is the problem. I’m tried calling ExpireSolution(true) from the listener and that’s a different thread. So I have to call ExpireSolution from the ‘Main Tread’. What would be the standard way to signal an event from some background worker thread to the main UI thread? I guess I have to do some reading on Grasshopper and multi threading…

See you
Flo


(David Rutten) #4

There’s a method on Rhino.RhinoApp for marshalling calls to the UI thread. Can’t remember its exact name.


#5

Hi David,
thanks for the hint. I guess its RhinoApp.InvokeOnUiThread. I’m going to try it.

See you
Flo


#6

Hi,
I tried to invoke ExpireSolution from the main tread, using InvokeOnUiThread but it’s not working. Well, InvokeOnUiThread works, the invoked method really gets called from the main UI thread, but ExpireSolution(true) does not seam to have any effect, the SolveInstance method of the assembly does not get called.

I’m still missing something, any idea what?

See you
Flo