In perusing through the UR and Polyscope manuals, I am having a hard time telling the difference between the efficiency and use of the “Thread” command, and the “Event” command. Is “Thread” used to contain a number of various commands as a way of organization, whilst “Event” is reserved for simpler tasks?
Any help would be appreciated, thanks
“Threads” in programming are parallel tasks. They run AT THE SAME TIME as your main program. This can be useful for monitoring inputs or other sensor values. Think of this as another Main Program.
Events are exactly the same thing as a thread, it’s just that Polyscope does a little more house keeping for you. In effect, it will run the code contained in the event ONCE per desired input condition. In fact, the script code Polyscope generates is just a thread:
In short, an event does nothing that a thread cannot do, it just does a little bit of additional prep work for you if you want code to run ONCE as opposed to continuously
It is a little misleading saying it will run ONCE, isn’t it? It’s a while-command and will act entirely as a thread and loop itself continuously as long as the input is true.
If you want to only run the event once, the event input must be set false before the execution of the last command (or as the last command) of the event.
Oops, yep you’re 100% correct!
The other thing to be careful about with events is that IF you have multiple events configured and event A is configured to execute first (within polyscope) and event B is second, IF and while event A is active only it will execute (out of all the events) and event B will not execute. If event B is active (while event A is not) and then event A becomes active the code under event A will execute and event B will not.
I agree this is not exactly intuitive but it is the way it works.
Now a straight thread(s) that is/are configured WILL run regardless of which event is active. Events do not affect threads but they can affect other events.