Questions about the sleep implementation
I saw many articles on [support center] to implement the sleep/delay function.
The two methods I've found are:
both works fine!!
However, a problem arises during development.
- Use the WebUtils unit
uses WebUtils;
procedure Tfrm_SubDash.WebButton1Click(Sender: TObject);
begin
//delay
Await(boolean, AsyncSleep(1000));
end;
- Use JavaScript directly
procedure Tfrm_SubDash.WebFormCreate(Sender: TObject);
begin
asm
window.sleep = async function(msecs) { return new Promise((resolve) => setTimeout(resolve, msecs)); }
end;
end;
procedure Tfrm_SubDash.WebButton1Click(Sender: TObject);
begin
//delay
asm await sleep(1000); end;
end;
■■■ Both of the above work well.■■■
However, a problem arises during development.
*** FYI, I'm developing with Delphi 10.3.
Case 1
uses WebUtils;
As above, WebUtils; If I do
Delphi code autocompletion does not work.
For example WebButton1. If you enter , the code auto-completion window should appear, but it does not appear.
Case 2
asm end;
If I type the phrase and hit enter, [end;] is automatically created again.
ex)
asm await sleep(1000); end; (Enter)
end; <-- added automatically
I'm having trouble with the problem in 1) and 2) above.
Any workaround?