//try my code:
unit uthreadtest;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
type
TTestThread = class(TThread)
protected
procedure Execute;
override;
end;
procedure TTestThread.Execute;
begin
while truedo
;
end;
var
TestThread: TTestThread;
procedure TForm1.FormDestroy(Sender: TObject);
begin
TestThread.Suspend;
TestThread.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
TestThread := TTestThread.Create(false);
end;
end.