Autor Beitrag
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 15.03.04 19:24 
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.

ausblenden 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!