Basically I have a Delphi application which downloads some data on run time, it basically executes Form.OnCreate; and then ENABLES a TTimer component to do the downloading. This has been working fine for me as at least the user sees the interface whilst it's loading but now I have a problem.

I am trying to update the FormCreate so it has a loading icon like this:
http://logd.tw.rpi.edu/files/loading.gif

I have already created about 9 images for my own loading icon and I have it animated using ANOTHER TTimer component which is also enabled in the Form.OnCreate BEFORE the downloading TTimer. But the problem I have is the loading icon just freezes whilst it is loading/downloading and only starts working AFTER the downloading/loading is finished, making it completly useless :(.

Can someone help me to have a smooth loading bar like that at the same time it is downloading? Is there a certain way to create these things?

You probably need to do the downloading in a separate thread, so the main thread (which displays the icon) is not blocked by it (or use a different asynchronous method of downloading).

Thanks for your fast response pirtaeas, I thought TTimer was a simplified way of using multiple threads but I guess I'm wrong? Or maybe it's just not powerful enough. I guess I'll have to give the complex way a try.

Have you got any neat tutorials for multithreading for starters?

Edited 4 Years Ago by DelphiGuy

I'll have to look, don't remember any. If you google "Delphi threading" you'll find plenty examples.

TTimer runs in the main thread unfortunately.

Thanks pirtaes, got it working like a treat now and I've even started programming with multithreading :D. You truely are a ledgend on the DaniWeb Delphi forums :D.

Lol, thanks... actually I think currently I am the only one trying to answer. Hardly any competition for legend status ;)

This article has been dead for over six months. Start a new discussion instead.