WEBApp and sleep

Hi,

Is in TMS Web Core some function which works like Delphi sleep?

I have to do something and after that I have to wait for the status change e.g:

while true do
  begin
    if(status) then break;
    sleep(2000);
  end;

Regards,

There is currently no sleep().
You'd typically handle this by a settimeout() in JavaScript or you could use the Delphi TWebTimer object

Ok ... thanks ... I will try use TWebTimer

Regards,

Another solution is using AsyncSleep() from the Rtl.HTMLUtils unit: delphi - How do I use the `Sleep()` procedure in TMS WEB Core? - Stack Overflow

So you can do this:

while true do
  begin
    if(status) then break;
    Await(boolean, AsyncSleep(2000));
  end;

Just remember to mark your procedure or function as an [async] method in the declaration of it.

2 Likes

Great @Shaun_Roselt thx for the inspiration, finally a little less lines of code