Background Thread?


#1

Hi,
is there a way to create a Rhino extension of some kind, that runs in the background while the user is still able to use Rhino (at least more or less) normally?

Thanks
Flo


Background screen capture thread
(Menno Deij - van Rijswijk) #2

It would really help if you give a concrete example of what you want to do. Many “background” actions can be achieved using event-driven programming, where your code responds to user actions, like adding, changing and removing objects.


#3

Hi,
there are two scenarios that I’m thinking about.

One think I was thinking about some time ago, is to perform computational intense calculations in background, while the user is able to use Rhino normally.

The other current problem is related to simulation and machine control. It would be nice to be able to have a background thread constantly receiving for example sensory data or status information from a physical system and based on this information updating or manipulation a Rhino drawing.

To some extend this is possible by writing a Rhino Python script that starts a new thread then terminates the main thread. The new thread keeps on running even after user control is handed back to the Rhino GUI again. For some reason this works, but its obviously not very stable nor is it supported, it seams to work by accident only. :slight_smile:

See you
Flo


(Menno Deij - van Rijswijk) #4

As far as I know, using these scenarios is possible. It is important, however, to interact with Rhino only on the main (GUI) thread. So, from your background thread, you need to call the main thread.

This can be achieved in C# using the Dispatcher, among other things. I’m not familiar with Python threading to tell you how to do this in Python.


#5

Hi,
ah, ok. sounds good. Any idea where I might start to gather more information. C# would be OK, I’d prefer C++ or Python though, I guess I need the to use the SDK and nor simply write a Rhino script.

Flo


(Menno Deij - van Rijswijk) #6

Don’t get me wrong, it can be achieved in C#, C++ and Python (any multithreading programming environment really). As I am most familiar with C# I gave the example of Dispatcher. But C++ and Python are also able to do calls across threads.