C
coolingxyz
Unregistered / Unconfirmed
GUEST, unregistred user!
多个线程 *****在线等******(50分)<br />unit mythtead;
interface
uses
Classes, SysUtils, Forms, mystruct, Windows;
type
Tmythread = class(TThread)
private
{ Private declarations }
SbIp: String;
SbPort: Integer;
SbData: String;
// PPFhIp : PstrIp ;
protected
procedure Execute;
override;
Procedure MainMemoShow;
Public
{ Public declarations }
Constructor Create(sSbIp: String;
iSbPort: Integer;
sSbData: String);
end;
implementation
uses main;
{ Tmythread }
Constructor Tmythread.Create(sSbIp: String;
iSbPort: Integer ;sSbData: String);
begin
inherited Create(True);
SbIp := sSbIp;
SbPort := iSbPort;
SbData := sSbData;
// PPFhIP := pPPFhIp;
Resume;
end;
procedure Tmythread.Execute;
begin
{ Place thread code here }
FreeOnTerminate := True;
//线程做完一遍后终止
Synchronize(MainMemoshow);
end;
Procedure Tmythread.MainMemoShow;
begin
frmfh.MemoShow.Lines.Add('Ip:' + SbIp + '端口:' + IntTostr(SbPort) + '返回状态码');
end;
end.
procedure mainform.SpeedButton1Click(Sender: TObject);
var //按了很多次,也不会出错的。为什么呀,照理要出错了呀。
mth : TMyThread;
begin
mth := TMyThread.Create('1234',123,'afdkaf');
end;
interface
uses
Classes, SysUtils, Forms, mystruct, Windows;
type
Tmythread = class(TThread)
private
{ Private declarations }
SbIp: String;
SbPort: Integer;
SbData: String;
// PPFhIp : PstrIp ;
protected
procedure Execute;
override;
Procedure MainMemoShow;
Public
{ Public declarations }
Constructor Create(sSbIp: String;
iSbPort: Integer;
sSbData: String);
end;
implementation
uses main;
{ Tmythread }
Constructor Tmythread.Create(sSbIp: String;
iSbPort: Integer ;sSbData: String);
begin
inherited Create(True);
SbIp := sSbIp;
SbPort := iSbPort;
SbData := sSbData;
// PPFhIP := pPPFhIp;
Resume;
end;
procedure Tmythread.Execute;
begin
{ Place thread code here }
FreeOnTerminate := True;
//线程做完一遍后终止
Synchronize(MainMemoshow);
end;
Procedure Tmythread.MainMemoShow;
begin
frmfh.MemoShow.Lines.Add('Ip:' + SbIp + '端口:' + IntTostr(SbPort) + '返回状态码');
end;
end.
procedure mainform.SpeedButton1Click(Sender: TObject);
var //按了很多次,也不会出错的。为什么呀,照理要出错了呀。
mth : TMyThread;
begin
mth := TMyThread.Create('1234',123,'afdkaf');
end;