Solved

Multi Threading???

Posted on 1998-11-26
2
207 Views
Last Modified: 2012-05-04
I've created a simple TThread object that downloads a file via FTP protocol.  Everything seems to be working fine except that the main form is very sluggish while threads are running.  Also threads tend to freeze system at end of downlaod.  Any help or pointers to thread documentation would be appreciated.

Here's the code:

unit uFtpThread;

interface

uses
  Classes, agFtp, agFTPCls;

type
  TFtpThread = class(TThread)
  private
    FTargetFileName : String;
    FLocalFileName : String;
    FFtp : TagFtp;
    procedure DownloadFile;
  protected
    procedure Execute; override;
  public
    constructor create(Ftp : TagFtp; sTargetFilename, sLocalFileName : String);
  end;

implementation

constructor TFtpThread.create(Ftp: TagFtp; sTargetFilename,
  sLocalFileName: String);
begin
  inherited Create(False);
  FreeOnTerminate := True;
  FFtp := Ftp;
  FTargetFileName := sTargetFilename;
  FLocalFileName := sLocalFileName;
end;

procedure TFtpThread.DownloadFile;
begin
  FFtp.RetrieveFile(FTargetFileName, FLocalFileName);
end;

procedure TFtpThread.Execute;
begin
  DownloadFile;
end;

end.
0
Comment
Question by:sparklin
2 Comments
 

Author Comment

by:sparklin
ID: 1348162
Edited text of question
0
 
LVL 4

Accepted Solution

by:
jack_p50 earned 100 total points
ID: 1348163
You should set Thread's priority level to low/lowest so it doesn't freeze system. Also you should check how many such Threads are active and than manage their priorities, so sum
of resources useing by all threads be almost constant(not depends on number of Threads)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now