3
336764
Unregistered / Unconfirmed
GUEST, unregistred user!
找了一晚上有关线程的东西,还是没搞懂。
unit c1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdExplicitTLSClientServerBase, IdFTP, ComCtrls, StdCtrls, Buttons;
type
Th = class(TThread)
private
IdFTP: TIdFTP;
OpenDialog: TOpenDialog;
//线程里能使用opendialog吗?
procedure Upload;
{ Private declarations }
protected
procedure Execute;
override;
public
constructor Create(isRun:Boolean);
end;
type
Tc1_form = class(TForm)
ProgressBar1: TProgressBar;
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
c1_form: Tc1_form;
TTh : TThread;
implementation
{$R *.dfm}
constructor Th.Create(isRun:Boolean);
begin
IdFTP := IdFTP.Create;
inherited Create(isRun);
end;
procedure Th.Upload;
begin
IdFTP.Host := 'localhost';
IdFTP.Username := 'upload';
IdFTP.Password := 'upload';
IdFTP.Connect;
showmessage('已经通过线程连接了数据库。');
//这里是打开选择文件的窗口,然后选择一个文件就put上去...
end;
procedure Th.Execute;
begin
{ Place thread code here }
Upload;
end;
procedure Tc1_form.Button1Click(Sender: TObject);
begin
TTh := Th.Create(true);
//这里要怎么写能执行该线程?
end;
end.
为何我一运行就说TIdFTP class 不存在??????
我对线程一点儿不了解,找了半天资料才找到一点点初级的,完全没概念
程序目的:
把IdFTP放入单独的线程运行,从而不影响主线程的界面。
另外,希望有朋友发个最为简单的线程的代码学习一下。
比如 按一个按钮,然后在5个线程中计算5个公式的结果等这么简单的。。。
谢谢。。。
unit c1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdExplicitTLSClientServerBase, IdFTP, ComCtrls, StdCtrls, Buttons;
type
Th = class(TThread)
private
IdFTP: TIdFTP;
OpenDialog: TOpenDialog;
//线程里能使用opendialog吗?
procedure Upload;
{ Private declarations }
protected
procedure Execute;
override;
public
constructor Create(isRun:Boolean);
end;
type
Tc1_form = class(TForm)
ProgressBar1: TProgressBar;
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
c1_form: Tc1_form;
TTh : TThread;
implementation
{$R *.dfm}
constructor Th.Create(isRun:Boolean);
begin
IdFTP := IdFTP.Create;
inherited Create(isRun);
end;
procedure Th.Upload;
begin
IdFTP.Host := 'localhost';
IdFTP.Username := 'upload';
IdFTP.Password := 'upload';
IdFTP.Connect;
showmessage('已经通过线程连接了数据库。');
//这里是打开选择文件的窗口,然后选择一个文件就put上去...
end;
procedure Th.Execute;
begin
{ Place thread code here }
Upload;
end;
procedure Tc1_form.Button1Click(Sender: TObject);
begin
TTh := Th.Create(true);
//这里要怎么写能执行该线程?
end;
end.
为何我一运行就说TIdFTP class 不存在??????
我对线程一点儿不了解,找了半天资料才找到一点点初级的,完全没概念
程序目的:
把IdFTP放入单独的线程运行,从而不影响主线程的界面。
另外,希望有朋友发个最为简单的线程的代码学习一下。
比如 按一个按钮,然后在5个线程中计算5个公式的结果等这么简单的。。。
谢谢。。。