本文整理自网络,侵删。
delphi取代Sleep的延时代码
procedure Delay(msecs:integer);
var
Tick: DWord;
Event: THandle;
begin
Event := CreateEvent(nil, False, False, nil);
try
Tick := GetTickCount + DWord(msecs);
while (msecs > 0) and (MsgWaitForMultipleObjects(1, Event, False, msecs, QS_ALLINPUT) <> WAIT_TIMEOUT) do
begin
Application.ProcessMessages;
msecs := Tick - GetTickcount;
end;
finally
CloseHandle(Event);
end;
end;
相关阅读 >>
学习使用Delphi for android 调用java类库
Delphi 使用tnethttprequest / tnethttpclient访问web服务器
更多相关阅读请进入《Delphi》频道 >>