Einzelnen Beitrag anzeigen

Dax
(Gast)

n/a Beiträge
 
#4

Re: Aktion im Hintergrund wiederholen [TObject]

  Alt 10. Jan 2005, 16:12
Ein Beispiel
Delphi-Quellcode:
uses ... Classes, Windows, ...;

type
  TMyThread = class(TThread)
  private
  protected
    procedure Execute; override;
  end;

{...}

implementation

{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure TMyThread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }


{ TMyThread }

procedure TMyThread.Execute;
begin
  { Schreibe hier deinen Code Rein ;-) }
  Sleep(1000); // damit der Code nur jede Sekunde ausgeführt wird
end;
PS: Dieses "Beispiel" stammt direkt aus der Delphi-IDE
  Mit Zitat antworten Zitat