Y
yitang
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,bytearray, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
Function getthreadcount():word;
private
{ Private declarations }
procedure threaddestroy(Sender:Tobject);
public
{ Public declarations }
end;
var
Form1: TForm1;
ThreadCount:word;
implementation
uses unit2;
{$R *.dfm}
procedure Tform1.threaddestroy(Sender:Tobject);
begin
inc(Threadcount,-1);
end;
function TForm1.getthreadcount():word;
begin
result:=threadcount;
end ;
procedure TForm1.Button1Click(Sender: TObject);
var
n:word;
begin
ThreadCount:=5;//这里简化了,只是想说明最终会创建5个线程
for n:=1 to 5do
begin
with mythread.createdo
//线程已经inherited create(false),FreeonTerminate:=true
onterminate:=threaddestroy;
end;
//到这里,我想执行完刚刚创建的5个线程之后再继续下面的的代码,请问如何实现?
//code
...
...
...
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,bytearray, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
Function getthreadcount():word;
private
{ Private declarations }
procedure threaddestroy(Sender:Tobject);
public
{ Public declarations }
end;
var
Form1: TForm1;
ThreadCount:word;
implementation
uses unit2;
{$R *.dfm}
procedure Tform1.threaddestroy(Sender:Tobject);
begin
inc(Threadcount,-1);
end;
function TForm1.getthreadcount():word;
begin
result:=threadcount;
end ;
procedure TForm1.Button1Click(Sender: TObject);
var
n:word;
begin
ThreadCount:=5;//这里简化了,只是想说明最终会创建5个线程
for n:=1 to 5do
begin
with mythread.createdo
//线程已经inherited create(false),FreeonTerminate:=true
onterminate:=threaddestroy;
end;
//到这里,我想执行完刚刚创建的5个线程之后再继续下面的的代码,请问如何实现?
//code
...
...
...
end;
end.