?
Solved

Multi Threading???

Posted on 1998-11-26
2
Medium Priority
?
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

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

Accepted Solution

by:
jack_p50 earned 200 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

752 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