Delphi已经提供毫秒延时函数,但是使用sleep会导致程序短暂pending;
sleep(1);表示延时1ms
自己要是实现的话,代码如下[luther.gliethttp]
以下是代码片段:
procedure TForm1.Delay(MSecs: Longint);
//延时函数,MSecs单位为毫秒(千分之1秒)
var
FirstTickCount, Now: Longint;
begin
FirstTickCount := GetTickCount();
repeat
Application.ProcessMessages;
Now := GetTickCount();
until (Now - FirstTickCount >= MSecs) or (Now < FirstTickCount);
end;
阅读(2182) | 评论(0) | 转发(0) |