Q&A

  • 쓰레드 실행중인지 체크하는 방법좀 부탁함당...
unit Unit1;



interface



uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls;



type

TForm1 = class(TForm)

Memo1: TMemo;

Button1: TButton;

Memo2: TMemo;

Button2: TButton;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;



type

TBackup1 = class(TThread)

protected

procedure Execute; override;

end;



type

TBackup2 = class(TThread)

protected

procedure Execute; override;

end;



var

Form1: TForm1;



implementation



{$R *.DFM}



procedure TForm1.Button1Click(Sender: TObject);

var

Backup1 : TBackup1;

begin

// 여기에다 TBackup1이 실행중인 걸 체크해서 실행중임 Exit로 빠지고 싶어요...

Backup1 := TBackup1.Create(True);

Backup1.Priority := tpNormal;

Backup1.Resume;

end;



procedure TForm1.Button2Click(Sender: TObject);

var

Backup2 : TBackup2;

begin

// 여기에다 TBackup2이 실행중인 걸 체크해서 실행중임 Exit로 빠지고 싶어요...

Backup2 := TBackup2.Create(True);

Backup2.Priority := tpNormal;

Backup2.Resume;

end;



procedure TBackup1.Execute;

var

i : integer;

begin

for i := 0 to 5000 do

begin

Form1.Memo1.Lines.Add(IntToStr(i));

end;

end;



procedure TBackup2.Execute;

var

i : integer;

begin

for i := 0 to 5000 do

begin

Form1.Memo2.Lines.Add(IntToStr(i));

end;

end;



end.

0  COMMENTS