Einzelnen Beitrag anzeigen

calibra301

Registriert seit: 20. Mär 2009
95 Beiträge
 
Delphi XE8 Professional
 
#3

AW: Verständnisfrage Thread...

  Alt 13. Feb 2018, 09:53
Sorry

Delphi-Quellcode:

// Globale Variable in MainUnit:
var OutputEngine:TOutputEngine;

// Deklaration in anderer Unit:
type
 TOutputEngine = class(TThread)
 Private

 public
   RunActive:Boolean;
   constructor Create;
   destructor Destroy; override;
   procedure Execute(); override;
   Procedure PreRun;
   Procedure PostRun;
end;

// StartButton im Mainform:
OutputEngine:=TOutputEngine.Create;
OutputEngine.Priority := tpHigher;
OutputEngine.RunActive:=true;
OutputEngine.Execute;

// Dann in Schleife
Procedure TOutputEngine.Execute;
var i:Integer;
    Time:Word;
Begin
  PreRun;
  Time:=0;
  while RunActive=true do
  Begin
    // Arbeite diverses Elend ab so lange Runactive=true;
  End;
  application.ProcessMessages;
  End;
  PostRun;
End;
  Mit Zitat antworten Zitat