时间定时问题,我想在一条语句执行之后定时一定的时间后再执行下一条语句,如
i:=i+1;
定时一定的时间(单位为毫秒)的语句
i:=0;请问除了使用Sleep方法之外还有其它什么办法,
i:=i+1;
定时一定的时间(单位为毫秒)的语句
i:=0;请问除了使用Sleep方法之外还有其它什么办法,
解决方案 »
- 求一行代码
- 对于“<a id="mb" href="/cf/fr?in=o">查看</a>”,属性变量有id、href等等,那么“查看”的属性变量是什么?
- delphi中调用ACCESS的UPDATE语句时出错,有谁遇到过这种情况啊?急!!!
- 最后一点分了,关于Object Passcal语法的两个疑问,请高手进来帮忙.真心谢过了.
- 社会底层人物的前世
- 一个已藏在心中N久的疑惑,请大家谈谈意见(关于学习DELPHI)
- 如何对临时表进行汇总?
- 我现急用sql6.5,我没有product id,安装时需要输入吗还有...
- 谁有ADOExpress升级包的序列号?
- 朱小军请进!
- 关于DBGridEh排序的问题,急急急!!!
- 如何用树状控件 显示硬盘上的所有文件?
{
if ()
{
}
}效率有点底下,还不如用Sleep
i:=i+1;
定时器打开
i:=0;上面的方法可以,但如果你需要精确时间的花就不可以了,因为各个计算机CPU的频率等原因所以上面的方法时间不准
// 1. Delay
procedure Delay(dwMilliseconds: Longint);variStart, iStop: DWORD;beginiStart := GetTickCount;repeatiStop := GetTickCount;Application.ProcessMessages;until (iStop - iStart) >= dwMilliseconds;end;// 2. Delay: with APIprocedure Delay(msecs: Longint);vartargettime: Longint;Msg: TMsg;begintargettime := GetTickCount + msecs;while targettime < GetTickCount doif PeekMessage(Msg, 0, 0, 0, PM_REMOVE) thenbeginTranslateMessage(Msg);DispatchMessage(Msg);end;end;{Note:The elapsed time is stored as a DWORD value.Therefore, the time will wrap around to zero if the system isrun continuously for 49.7 days.}// 3. Sleep{The Sleep function suspends the execution of the currentthread for a specified interval.}Sleep(dwMilliseconds: Word); // 4. Combined Delay{Including the Sleep in the loop prevents the app from hogging100% of the CPU for doing practically nothing but running around the loop.}procedure PauseFunc(delay: DWORD);varlTicks: DWORD;beginlTicks := GetTickCount + delay;repeatSleep(100);Application.ProcessMessages;until (lTicks <= GetTickCount) or Application.Terminated;end;还可以用SleepEx函数。