Mein letzter Beitrag dazu...
himitsu hat vollkommen recht.
Hier noch mal eine abgewandelte Version:
Delphi-Quellcode:
procedure TForm5.StarteThread;
Var temp : String;
Watch : TStopwatch;
begin
Label1.Caption := 'Thread running';
Button1.Enabled := False;
Watch := TStopWatch.Create();
Watch.Start;
TThread.CreateAnonymousThread(
procedure
begin
try
Sleep(5 * 1000); // Wait 5 secs
temp := 'Ich habe fertig';
// Oder halt Dein GetHttp
//temp := GetHttp('wasauchimmer');
finally
TThread.Synchronize(nil,
procedure
begin
Watch.Stop;
FinishTread(temp, Watch.ElapsedMilliseconds);
Button1.Enabled := true;
end);
end;
end).Start;
end;
procedure TForm5.FinishTread(const Value: string; const Millisecs : int64);
begin
Label1.Caption := format('Message: %s time in Miilsecs %d',[Value, Millisecs]) ;
end;