Hab das jetzt so gelöst jetzt funktioniert es allerdings lässt sich das fenster nicht mehr verschieben wenn der Thread am zählen ist.
Delphi-Quellcode:
type
ParseThread = class(TThread)
private
{ Private-Deklarationen }
Form1: TForm1;
i:integer;
protected
procedure Execute; override;
procedure DoSomething;
public
{ Public-Deklarationen }
constructor Create(Form1: TForm1);
end;
var
Form1: TForm1;
tt: ParseThread;
implementation
{$R *.dfm}
procedure ParseThread.Execute;
begin
while not Terminated do
begin
Synchronize(DoSomething);
end;
end;
procedure ParseThread.DoSomething;
begin
inc(i);
form1.Memo1.Lines.Add(inttostr(i));
if i = 5000 then begin
i:=0;
SuspendThread(tt.Handle);
end;
end;
constructor ParseThread.Create(Form1: TForm1);
begin
inherited Create(False);
Self.Form1 := Form1;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
tt := ParseThread.Create(Self);
tt.FreeOnTerminate := true;
end;
end.