@async while loop not looping

Im trying to loop two tasks but it will only run through it once and not loop. This is what my code looks like. I have the second task commented out because im trying to just get the first one working.

If i remove the @async then it throws an error of the task not being runnable.

TPH = @task (GetTPH());
Mak = @task (MakieWindow());


function ttt()
    @async while true
    schedule(TPH);
    wait(TPH);
    #schedule(Mak);
    #wait(Mak);
    sleep(5)
    end
end

I am new to tasks and trying to get a Gtk and Makie to update and run variables simultaneously.

Thanks,
W

After the first loop iteration, the task TPH is done and cannot be scheduled again.

But it looks like you want GetTPH and MakieWindow to run sequentially anyway, so why not simply do

function ttt()
    @async while true
        GetTPH()
        MakieWindow()
        sleep(5)
    end
end

Ya know sometimes you just overthink everything… That worked!

I believe i was overthinking it because Gtk uses some funny button/function callbacks that i initally setup but then never considered changing. (I was also looking for a change to understand tasks better).

just out of curiosity why cant the task be scheduled again?