Checking end of sequence on main thread

Hi,
I have one question that I couldn’t find answer for.
I am trying to check when the sequence is over, and I’m trying the following example code:

bool test = false;

this->runAction(
	Sequence::create(
		DelayTime::create(5), 
		CallFunc::create([&test]() {test = true; }), 
		nullptr));

while (!test);

And the variable test is never changing to true so the execution is stuck at while (!test);
When I delete the while loop the variable test is changing to true after some time but with the loop is simply stuck.
Do I miss something ???
Is there other more elegant way of stopping the execution of the main thread until the sequence is over ?
Thanks in advance :smile:

Hi,

When you use while loop you probably pause the main thread, so your action (and probably all other code) do not working.

Hi igormats,
Thakns for the reply, I undestood it, but is there some way to pause the execution of the main thread untill the sequence is done ?

I think nope because updates of any action is also running in the main thread (main thread is calling update actions of all Nodes).
I believe you need to find another way instead of pause the main thread.

Thanks :smile: