delphi真正实现延时暂停功能

用delphi怎么实现延时功能?在delphi中有一个sleep()函数是用来暂停线程的,使用了它好像和死掉了似得,不好用,这么简单的延时动作用Timer控件有显得复杂了。
下面给大家分享一个真正好用的延时功能:

procedure delay(MSecs:LongInt);
var
  FirstTickCount,Now:LongInt;
begin
  FirstTickCount:=GetTickCount();
  repeat
    Application.ProcessMessages;
    Now:=GetTickCount();
  until (Now - FirstTickCount >=MSecs)or(Now<FirstTickCount);
end;
//调用
delay(1000);//延时一秒

 

posted @ 2020-03-12 13:51  李先森°  阅读(1209)  评论(0编辑  收藏  举报