Function called at SCREEN_LOADED not executed when it contains "infinite" while


on a screen2 I added the EVENT trigger SCREEN_LOADED which calls a function
this function works fine until I add a while loop which waits for a number of serial inputs.

function dosomething() {
int numvalues=10;
char buf[32];
lv_dropdown_get_selected_str(ui_Dropdown2, buf, sizeof(buf));
lv_textarea_add_text(ui_TextArea1, buf);

while (i<numvalues) {
  if (hc12.available()) {
    message = hc12.readString(); 
      if (message.substring(0,3)=="123") {

It interrupts the MOVE LEFT animation sequence from screen1 to screen2 at about 90% and prevents the add_text.
By using READY instead of SCREEN_LOADED the animation sequence finishes but the add_text doesn’t happen.

How can I get around this?

Event is named as is. Code used in events require low time as possible and no blocking wait. Every block stop GUI .
When you require init visible objects on load screen , then values to show must be know before. When is available only after update it when arrive

Ok thanks, found a way, not elegant but working by setting a status in event function and returning to the loop.

For the variables of course they are known. From screen 1, output was just blocked from the while loop.