delphi延时  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi延时


// 高精度的延时,精确到Ms , 100ms以内采用,或要求误差极小
// 删除Application.ProcessMessages 影响精度
procedure DelayMsEx(Ms: LongWord);
var
  iFreq, iStartCounter, iEndCounter: Int64;
begin
  QueryPerformanceFrequency(iFreq);
  QueryPerformanceCounter(iStartCounter);
  repeat
    QueryPerformanceCounter(iEndCounter);
    //Application.ProcessMessages;
  until ((iEndCounter - iStartCounter) >= Round(Ms * iFreq / 1000 ));
end;
 
 
// 精度很低,50ms以外还能凑活
// 及时去除 Application.ProcessMessages 误差也极大
// 仅适用误差要求不高,延时较长的场合
procedure DelayMs(Ms: LongWord);
var
  dwStartTime: LongWord;
begin
  dwStartTime := GetTickCount;
  repeat
    Application.ProcessMessages;
  until ((GetTickCount - dwStartTime) >= Ms);
end;

来源:https://blog.csdn.net/w709835509/article/details/17486943

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.038356065750122 seconds