I am using a TMSFNCWebBrowser to download JSON for processing. I have everything working but I had to add sleep commands since I am unaware of another way to get the program to work correctly.
I navigate to the URL and wait for a flag to be set in the OnNavigateComplete event. I am not aware of a method to determine if the document has fully been downloaded so I ProcessMesages and sleep for two seconds.
These steps work well but I have at least a 4.1 seconds delay each time I download another page of JSON.
How can I detect when the document download has been completed?
I have tried leaving the sleep statements out but I don't get then I get a partial JSON document.
Here is the code:
Tries := 0;
f_NavigateComplete := False;
while (not f_NavigateComplete) and (Tries <= 100) do
Tries := Tries+1;
if f_NavigateComplete then
procedure(const AValue: string)
S := LJSONValue.ToString;
S := StringReplace(S,'"','"',[rfReplaceAll]);
S := StringReplace(S,'\','',[rfReplaceAll]);
S := StringReplace(S,'/','',[rfReplaceAll]);
ContentMemo.Text := S;
ContentMemo.Text := '';