unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
Tt = class(TThread)
protected
procedure Execute; override;
public
h: Thandle;
c: integer;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
t: tt;
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
t := Tt.Create(false);
end;
{ Tt }
procedure Tt.Execute;
begin
c := 0;
h := CreateEvent(nil, false, false, 'AA');
while not Terminated do
begin
waitforsingleobject(h, 30000);
inc(c);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SetEvent(t.h)
end;
end.