How can i get out of Thread and continue Robot Program?


Is there a way to control program flow when working with a thread? My program goes to thread by initializing a variable in “Before Start” and executes a script file within the thread.Then it gets stuck in the Thread. I want it to go back to Robot Program (main program) and continue from there.
i marked the execution order on the screen shot . I want program to go the 5.step . I know Thread works parallel to main program , but if that’s the case why main program does not take over when the variable(NextState) is set ?

Thank you in advance!

This could be a variable scope issue. You might be creating a local copy of your state variable in the script block.

I suggest using flags to turn the thread on and off instead of sharing a state variable between robot program and thread. This is a messy structure that you may regret.

Just have one state switch in robot program where whoever is debugging your code can look at the state transitions, and then have those states use booleans to enable/disable threads.