The program often downloads from the Internet, in itself, it does not take a lot of time, but some people have slow Internet. Therefore, how can you make sure that during the operation of one procedure it shows some kind of download, even just the same frame with animation, just so that the user can see that the program works and does not hang.

  • one
    To do this, you need to transfer the download to a separate thread TThread . - KiTE
  • with THTTPSend.Create do begin ProxyHost: = '127.0.0.1'; ProxyPort: = '8118'; if HTTPMethod ('GET', AnsiToUtf8 (URL)) then begin Jtop: = TStringStream.Create; Jtop.FromStream (Document) // Below is the code for working with the stream .... - zerpico
  • And the way I do it does not affect. If I download 10 files. then no matter how long it will be anyway, I need to do something like a display of expectations. for example, to get out the frame with the words "wait" and the clock. - zerpico
  • one
    Use ICS components. They already use threads, besides thread safe, unlike Indy for example ... - Yura Ivanov
  • 2
    So answered the same! Transfer download to stream. A thread (TThread) is one that allows you to do anything in the background. Your forms work in the main application flow. If downloading is done in an additional stream, the program will not hang. And @Yura Ivanov suggested not to reinvent the wheel, but to take and, at once, use components for downloading, in which the work in the background is realized out of the box. - KiTE September

2 answers 2

@Pandakun , I’ll give another thought to @KiTE :

  • Show the window in which the animation will be drawn. You can use the normal window with BorderStyle = bsNone . You can show TPanel in the open window, on top of other components.
  • Start the download. In any implementation, the download should go in a separate thread.
  • Draw the loading indicator on the created panel / window as you like. Although the outline of the timer, even though TProgressBar , at least some TAnimate .
  • After the download is complete, remove your panel / window.

And the way I do it does not affect.

A separate stream for downloading is needed so that you do not hang the drawing of the window with the indicator.

  • Yeah, this is reasonable, but can a small example be just how to download a file from the Internet via ICS? - zerpico
  • Alas, I am not familiar with ICS. - Nofate
  • And in any other way, I just don’t quite understand what a "separate stream" is - zerpico

And in any other way, I just do not quite understand what a "separate stream"

An example of working with threads in this link .