Solved

Multi Threading???

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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