Durch die Anwendung von
MsgWaitForMultipleObjects mit dem Thread-Handle des eigenen Threads wird der Thread solange schlafengelegt, bis entweder ein Timeout eintritt, oder eine Message aus der Message-Queue abgearbeitet werden muss.
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
| procedure Delay(dwMillSec: DWord); var aHandle: THandle; dwStart:DWord; begin aHandle := GetCurrentThread; dwStart := GetTickCount + dwMillSec;
while MsgWaitForMultipleObjects(1, aHandle, False, dwMillSec, QS_ALLINPUT) <> WAIT_TIMEOUT do begin Application.ProcessMessages; dwMillSec := GetTickCount; if dwMillSec < dwStart then dwMillSec := dwStart - dwMillSec else Exit; end; end; |
_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!