Script wait in CustomComponent

Hi,
I’m using

script.execute: test1
script.wait: test1

to block execution of my main program until test1 has finished. It works perfectly. But now I coded some logic in a customComponent as C-Code. To achieve same behaviour I tried:

id(test1).execute();
ESP_LOGD("test_control", "test1 started");
while ( id(test1).script_is_running() ) {};
ESP_LOGD("test_control", "test1 finished");

But of course this doesn’ t work because my while statement blocks execution of other code (i.e. network-stuff).

My question: Is there another way to call a script from a customComponent and blocking execution of only this component until script is finished?
Thanks
tomesp