等待函数(界面保持响应正常)不同于Sleep

等待函数(界面保持响应正常)不同于Sleep


// 自定义函数

procedure WaitTime(MSecs: integer);
var
  FirstTickCount, Now: Longint;
begin
  FirstTickCount := Windows.GetTickCount();
  repeat
    Application.ProcessMessages;
    Now := Windows.GetTickCount();
  until
    (Now - FirstTickCount >= MSecs) or (Now < FirstTickCount);
end;



Eg: WaitTime(1000);

你可能感兴趣的:(等待函数(界面保持响应正常)不同于Sleep)