Delegate Sub delegateSet(ByVal str As String)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SuperLoop()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim SecLine As New Thread(New ThreadStart(AddressOf SuperLoop))
SecLine.Start()
End Sub
Private Sub SuperLoop()
Dim dlg As New delegateSet(AddressOf setText)
For i As Integer = 0 To 120
System.Threading.Thread.Sleep(1000)
Try
Label1.Text = i.ToString
Catch
Label1.Invoke(dlg, i.ToString)
End Try
Next
End Sub
Sub setText(ByVal val As String)
Label1.Text = val
End Sub