Einzelnen Beitrag anzeigen

Der schöne Günther

Registriert seit: 6. Mär 2013
6.110 Beiträge
 
Delphi 10 Seattle Enterprise
 
#4

AW: Sekunden in Millisekunden für Sleep umwandeln

  Alt 11. Mär 2017, 10:44
Deine Annahme dass ein Sleep(1) auch wirklich eine Millisekunde wartet ist falsch. Schau mal in die Windows-Doku zu Sleep: https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
Zitat:
The system clock "ticks" at a constant rate. If dwMilliseconds is less than the resolution of the system clock, the thread may sleep for less than the specified length of time. If dwMilliseconds is greater than one tick but less than two, the wait can be anywhere between one and two ticks, and so on.

Das soll den Vorteil haben, dass sich das Programm sofort beenden lässt und nicht erst in einer Sleep(1000) oder so festhängt.
Falls das deine Motivation ist dann ist Sleep nicht das richtige. Ich würde das mit WaitForSingleObject machen - Das ist im Endeffekt wie ein Sleep, aber wenn z.B. den Thread von außen terminieren möchte kann man es "abbrechen". Gibt im Forum bestimmt ein Beispiel. Wenn nicht, sag Bescheid.
  Mit Zitat antworten Zitat