Timer.CallLater

From Xojo Documentation

Shared Method

Timer.CallLater(afterMilliseconds As Integer, method As Timer.TimerCallLater)

New in 2019r2

Used to call a method (without parameters) once after the specified delay in milliseconds.


Shared Method

Timer.CallLater(afterMilliseconds As Integer, method As Timer.TimerCallLaterWithValue, value As Variant)

New in 2019r2

Used to call a method (with a parameter) once after the specified delay in milliseconds.

Notes

The method parameter is a delegate to a method that does or does not take a parameter. When passing a parameter, it must be an Variant passed as the last argument parameter.

Sample Code

Suppose you want to display some help text for a few seconds and then hide it. You can do this by creating a method to clear a Label (ClearLabel):

Sub ClearLabel
MyLabel.Value = ""
End Sub

In the initial method, you set the Label help text and then use CallLater to set it to clear it after 2 seconds:

MyLabel.Value = "Help text goes here"
Timer.CallLater(2000, AddressOf ClearLabel)

Suppose you want to display some help text for a few seconds and then replace it with different text. You can do this by creating a method that takes the text to display as a parameter (SetLabel):

Sub SetLabel(helpText As Variant)
MyLabel.Value = helpText
End Sub

In the initial method, you set up the Label help text and use CallLater to change it after 2 seconds:

MyLabel.Value = "First help text goes here"
Timer.CallLater(2000, AddressOf SetLabel, "Second help text goes here")