TTMSFNCImage LoadFromURL Failing to Load or is Partially Loading Some Images

Hi

Using Firemonkey, I'm programmatically creating "TTMSFNCImage"s on a TVertScrollBox and downloading images to each one from URLs using the TTMSFNCImage.Bitmap.LoadFromURL function. I have the following issue. Sometimes, some of the images are not being loaded, sometimes only a part of the image is being loaded.

Any way to make sure that all images are downloaded?

Moreover, how can I make sure that the first 2-3 images load before the other images are downloaded and loaded?

This is an example of the code I'm using:

procedure TForm1.LoadAllImages;
var
i: integer;
CurrentImage: TTMSFNCImage;
begin
for i:= 1 to 20 do begin
CurrentImage:= TTMSFNCImage.Create(VertScrollBox1);
TTask.Run(
procedure
begin
CurrentImage.Bitmap.LoadFromURL('https://mywebsite.com/Image'+i.ToString+'.jpg');
end);
CurrentImage.Parent:= VertScrollBox1;
end;
end;

Btw, the reason I'm using TTask is that if I don't use it, I'm getting an android.os.NetworkOnMainThread exception on Android.

Hi,

Can you provide a sample demonstrating this issue? Please note that when asynchronously loading the images, that potentially the refresh that is happening inside the LoadFromURL is not happening because it is on another thread. You need to synchronize updates with the main thread, so please call Synchronize(RepaintImage), and then the RepaintImage call simply calls TMSFNCImage1.Repaint;