Hallo Delphi-Helfer
Ich habe einen Dienst mit Timer und dieser Timer soll bestimmte Dinge prüfen und erledigen.
Der Timer tut das mitlerweile Problemlos.
Mein Problem ist, dass selbst wenn der Timer ausgeschaltet ist,
ServiceExecute permanent arbeitet und damit auf Leistungsschwachen PCs zu bis zu 70% Auslastung führt.
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| procedure TFÜDienst.ServiceExecute(Sender: TService); begin _FÜ.TimerZeit.Enabled := True;
while not Terminated do begin ServiceThread.ProcessRequests(False); end;
_FÜ.TimerZeit.Enabled := False; end; |
Ich habe es mit Sleep(1) probiert, bei mir funktioniert es, aber dafür kann ich den Dienst nicht anhalten oder beenden (verständlicherweise)
aber auf dem schwachen PC startet der Dienst garnicht, weil er nicht rechtzeitig antwortet.
Kann man dem ServiceExecute beibringen nur auf den Timer zu warten, aber auch sich zu beenden, wenn ich den Dienst beenden will?