unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Label1: TLabel;
lblCount: TLabel;
Label3: TLabel;
lblCountsPerSec: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private-Deklarationen }
OldCount: Integer;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type
TTestThread = class(TThread)
private
procedure Execute; override;
public
Count: Integer;
end;
var
TT: TTestThread;
procedure TTestThread.Execute;
begin
while not Terminated do
begin
Sleep(10);
Inc(Count);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
TT := TTestThread.Create(False);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
TT.Terminate;
TT.WaitFor;
TT.Free;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
lblCount.Caption := IntToStr(TT.Count);
lblCountsPerSec.Caption := IntToStr(TT.Count - OldCount);
OldCount := TT.Count;
end;
end.