[quote=165984:@Jakob Krabbe]Why are there two loops? One in the button and the second loop in the http.PageRecieved code?
If I call the pageRecieved cod inside the loop, in the button, it doesn’t work. It’s too fast.
[/quote]
I do not know what you may be doing, but I do not understand what you mean by “The code is not waiting for the response.”. Unless you messed it up real bad, that code precisely sends a Get request, then the asynchronous HTTPSocket waits patiently for the response and provides it in the PageReceived event.
There are no loops at all in the original code. All there is in the button is an initialization of the values in URLS().
The way it works is
- The first request for URLs(1) is done in the button
- When the page is received for URLs(1) the program checks the queue is not ended, sends a new request for the next URLs and increments URLIndex.
And so on, until the last item in URLs() is processed.
I placed the URLs values in the button, but they can be anywhere.
The ONLY code that should be in the button to start the process is
URLIndex = 1
http.Get(URLs(URLINdex))
If you attempt to do anything else after the get, you completely mess up the process. Probably why you think it is not in sync somehow.
The ONLY place where you should do some processing is in PageReceived.