Example 1) Specify timer ID 1 and a 1 second period.
In the above example, by not specifying delayRecoveryRate, even if multiple processes overlap and the timer occurrence is delayed, the next timer will be generated based on the time of the current occurrence.
Therefore, if the processing is heavy, the timer will become increasingly delayed, but the processing load will be constant, and the mouse response such as pressing a button will also be constant. It is suitable when you do not care much about a fixed periodicity. VB is one of these types of timers.
Example 2) Specify timer ID 1 and a 1 second cycle. Specify a recovery rate of 20%.
|
this.SetTimer(1, 1000, -1, 0.2, 10000);
|
In the above example, delayRecoveryRate is set to 20%. If the timer is delayed by other processing, the next timer occurrence is made earlier to ensure regular periodicity.
For example, if a timer is delayed by 500ms, the next timer will occur 500ms x 0.2 = 100ms earlier.
The timer fires little by little faster until the accumulated delay time reaches 0, resulting in a constant number of timer events per unit time (for example, 60 times per minute for a 1 second cycle).
When multiple processes are executed by multiple timers, an attempt is made to ensure a fixed periodicity, which often results in multiple processes being executed consecutively, resulting in disadvantages such as slow mouse response.
|