Threads and timers, how to manage multiple?

[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.

Dear Michel!
I would like to thank you with all the respect for being very supportive in this.
Now all is solved… and tomorrow, it will be five weeks since I started.

I need to sync different websites with each other, it’s a vital part of the project. Earlier I tried other alternatives.
This last post all explained the last question as I had to you: Why URLIndex need to be set to 1?

The other demons messing with my copy/paste code is http// in stead of http:// and finally, today, encodeURLComponent will make magic for names with spaces!

I must admit! I didn’t work night and day with these things. I also did other things along the way.
However, now I can move on with the project… if I can remember where I left off!! :slight_smile:

That’s for tomorrow!!
I lift my hat, thank you deeply for all the patience!

The array URLs contains the URL of each page to get.
The button starts the process of getting the first element of the array. Then the process renews itself each time a page is received, increments URLIndex and goes on.