Public Class Form1
Public Shared T As New System.Timers.Timer
Delegate Sub SetTextCallBack([text] As String) ' You're going to run into cross threading issues
' This is needed for a solution (see below)
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
T.Interval = 2000
AddHandler T.Elapsed, AddressOf T_Tick
T.Enabled = True
End Sub
Private Sub SetText(ByVal [text] As String)
' InvokeRequired required compares the thread ID of the
' calling thread to the thread ID of the creating thread.
' If these threads are different, it returns true.
If Me.InvokeRequired Then
Dim d As New SetTextCallBack(AddressOf SetText)
Me.Invoke(d, New Object() {[text]})
Else
Me.Text = [text]
End If
End Sub
Private Sub T_Tick(ByVal sender As Object, ByVal e As Timers.ElapsedEventArgs)
SetText("Ok")
T.Enabled = False
End Sub
End Class