In the SDK/Samples folder there is a concurrent context example. In the same two scripts are executed, script1/script2, with each script having a for loop that sleeps for 1 second. Within the main.cpp, the following function then causes the scripts to execute:
for(;;){// Check if any key was pressedif( kbhit() ){contextManager.AbortAll();break;}// Allow the contextManager to determine which script to execute nextcontextManager.ExecuteScripts();}
- Does the ExecuteScripts() method only call the main function in each thread? I assume this is true, but I can't find the answer within the contextmanager addon sourcecode. It would be good to know why ExecuteScripts is calling 'main' and if its limited to only operating on that interface method. It would be nice to be able to write a class with a method that is intended to be long-running and called by the ContextManager. I know I can get there by having an object instantiated in main and calling its methods.. but I'd like to avoid that if possible.
- This leads to my second question, what if I want to call a script function from the C++ side. For instance, what if I want to call Obj::SomeLongRunningMethod() that sleeps every 500 ms and performs some type of long-running state control.
Thanks very much