1. Timer 2. wait until true

Hello

I'm working on a big project. I used the clock component.
In it, when the timer goes off, I want it to wait until a variable is true.
I think it's something with while test.

Thank you in advance.

Dear @Lars_V ,
AI2 is single thread, this means that you cannot wait for a varibale that becomes true, by means of some external setting event (i.e. loaded by a BT reception). If you use a while block you'll remain stuck waiting forever.
What you can do is to use a clock that every "n" milliseconds reads the status of the variable, then exits and lets the program flow to proceed (and therefore the variable to be set by some other source). So you shall use two closks: the first is the one that you have already coded, the second is started by the first, and periodically verifies (not "waits" !) when the variable has become set. When this second timer detects that the variable has been set, it disables itself and lets the "waiting" code to go further.
Whether you want to deepen the item, you can also check other topics related to methods to implement a "delay" procedure.
Best wishes.

.

thanks

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.