This article is about the Timer object in the Microsoft Small Basic programming language.
In this article:
Timer is an object that generates timer events in a specified interval.
The Timer object has 1 property, 2 operations and 1 event.
The Timer has only one property - Interval. The default Interval is 100000000 [ms] (27.7 [h]).
Timer has one event.
The Timer object has the following two operations.
A timer event handler is a subroutine that is called when the interval has expired. There are two types to write event handlers. The first one does the target procedure in the event handler.
Timer
.
Interval
=
1000
Tick
OnTick
Sub
Pause
(
)
DoSomething
Resume
EndSub
Turtle
Move
10
The second one does the target procedure out of the event handler.
While
"True"
If
tick
Then
"False"
Else
Program
Delay
300
EndIf
EndWhile
The following are sample programs showing the use the Timer object.
There are two known issues about the Timer.
The Timer has about a 10ms error (delay). The error of the Timer can be easily confirmed with the Clock.ElapsedMillisecond property. A sample program has been published as ZHB659.
Short Timer.Interval (such as 20) is too heavy in remote (in a browser with Silverlight).