Link to home
Start Free TrialLog in
Avatar of sparklin
sparklin

asked on

Multi Threading???

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.
Avatar of sparklin
sparklin

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of jack_p50
jack_p50

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial