Solved

Multi Threading???

Posted on 1998-11-26
2
208 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

15 Experts available now in Live!

Get 1:1 Help Now