Multiple http Get requests to server - loop wait?

I have a DesktopImageViewer which loads an image from a server. It is based on this example.

It is working for me ok except when I want to use it for multiple images. If I put it in a for loop to load multiple different images, the loop runs faster than the time to load the image. This results in missing some of the images.

Is there a way to get the loop to wait for the image loading to complete before continuing?

Use a new control for each image to be downloaded.

Can I do that Dynamically?

Each control should only download one image. Are you trying to download & show images in a sequence? If you are then you need to request the next image in the ContentReceived method and you’ll probably need to call the method that requests the next image using Timer.Calllater to avoid errors.

If you post some code here I’ll have a look.

The images are displayed simultaneously. I would like to load them into an array to be accessed later.
The xojo file is pretty busy. Maybe you can make some sense of it. The interesting parts are “SpriteLoader” and “CanvasAnimation”

I would suggest you refactor your code making SingleObject a URLConnection and loading the image there. That way you’ll get each image when the object is created and you won’t be reusing the WebConnection which is not recommended.

1 Like

Thanks! That put me on track.