摘要
Visual Basic 6.0自带的Timer(定时器)控件的Interval(时间间隔)属性,可用来设置两次触发Timer事件的时间间隔,实现定时功能。由于系统硬件和该属性固有的限制,定时程序在运行过程中会出现定时误差大和时间间隔有限等不足,其定时误差约为5%。针对这两个问题,介绍了如何利用主动查询对比系统时间的算法,不断修正Timer控件的定时误差,防止误差的累积,从而实现高精度定时和任意整数秒时间间隔定时。经过实验测试,该算法可消除定时器的固有误差,达到无误差定时。
The interval property of Visual Basic 6.0 internal timer widget can be used to as a timing function by adjusting the time interval between two triggered timer events. Due to system hardware limitations and the intrinsic weakness of the widget, its performance is severely undermined by issues such as large errors and limited time intervals. The timing precision is about 5%. In order to solve these problems, the authors have developed a method to achieve more precise and arbitrary- integer-second-time-interval timing by utilizing an algorithm that actively checks and compares the system time and constantly corrects the error to prevent the accumulation of it. The experimental results show that this method can eliminate the inherent error and improve the accuracy of timer widget in triggering a certain event within any given time interval.
出处
《计算机应用》
CSCD
北大核心
2012年第A02期144-146,共3页
journal of Computer Applications