Xojo.Core.Timer.CallLater

From Xojo Documentation

Shared Method

Xojo.Core.Timer.CallLater(afterMsec As Integer, method As Xojo.Core.Timer.CallNoParams)

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


Shared Method

Xojo.Core.Timer.CallLater(afterMsec As Integer, method As Xojo.Core.Timer.CallWithArg, argument As Auto)

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 Auto 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"
Xojo.Core.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 Auto)
MyLabel.Text = 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"
Xojo.Core.Timer.CallLater(2000, AddressOf SetLabel, "Second help text goes here")