Registriert seit: 31. Jul 2003
Ort: Dresden
1.386 Beiträge
Delphi 7 Architect
|
Re: Thread Vs Timer !!! Wievile Threads sind zu viel ?
16. Sep 2003, 18:21
Delphi-Quellcode:
type
TTimerThread = class(TThread)
private
hClose : Cardinal;
public
constructor Create;
destructor Destroy; override;
procedure CloseMe;
procedure Execute; override;
end;
{ TTimerThread }
procedure TTimerThread.CloseMe;
begin
SetEvent(hClose);
end;
constructor TTimerThread.Create;
begin
inherited Create(false);
hClose := CreateEvent(nil, true, false, nil)
end;
destructor TTimerThread.Destroy;
begin
CloseMe; // schleife beenden
CloseHandle(hClose);
inherited;
end;
procedure TTimerThread.Execute;
var dw : Cardinal;
begin
repeat
dw := WaitForSingleObject(hClose, 60000);
if dw = WAIT_TIMEOUT then
Windows.Beep(200, 200); // mache irgentwas
until (dw = WAIT_OBJECT_0) or Terminated; // beendet
end;
Das könnte dir Helfen...
- ciao neo -
Es gibt niemals dumme Fragen, sondern nur dumme Antworten!
|
|
Zitat
|