This item was deprecated in version 2020r2. Please use Timer as a replacement.
Provides a way to run code at specified intervals.
Specifies when the timer gets called. (Off, Single, Multiple)
Disables the Timer. The action event handler is no longer called. This is the default.
Calls the Action event handler once after the Period is reached, then turns the Timer to Off.
Call the Action event handler each time the Period is reached.
Mode As Modes
Specifies if the timer calls the Action event handler once, multiple times or not at all using the Modes enumeration. The default is Xojo.Core.Timer.Modes.Off.
Setting Mode to Single or Multiple starts the Timer.
Set the Mode to Multiple:
Timer1.Mode = Xojo.Core.Timer.Modes.Multiple
Period As Integer
Specifies the number of milliseconds between calls to the Action event handler.
A period of 0 means to start the timer immediately on the next event loop and is useful for creating a Timer that runs as soon as possible. The Period is not precise as system events or blocking code can delay the call to the Action event handler.
Set the period to 1 second:
Timer1.Period = 1000
Tolerance As Integer
A hint to the system as to how precise (in milliseconds) you need the timer to be, although you may get less tolerance that this depending on what the operating system supports. A value of 0 (the default) means to use the standard for the platform. A value of 100 asks for 100 millisecond tolerance.
Any method that does not have a parameter can be used with CallLater and CancelCall.
CallWithArg(argument As Variant)
Any method with a single Auto parameter can be used with CallLater or CancelCall.
Called when the Timer interval is reached, based on the Mode and Period properties.
Timer code always runs in the main thread, shared with UI updates. A long-running process called by a Timer can make the UI unresponsive. In these situations, use a Thread instead.
This code updates an iOSProgressBar:
ProgressBar1.Value = ProgressBar1.Value + 1
' Stop Timer when ProgressBar reaches maximum
If ProgressBar1.Value > ProgressBar1.MaximumValue Then
Me.Mode = Xojo.Core.Timer.Modes.Off
Timers run on the main thread.
If you instantiate a Timer in code, you'll need to use AddHandler to direct the Action event to a method. Refer to the AddHandler page for an example.
All project types on all supported operating systems.