Here's a very simple and limited example of using a delegate to update your UI control from a background thread:
Public Delegate Sub UiUpdateDelegate(ByVal message As String)
Public updateMyUI As UiUpdateDelegate = AddressOf UpdateUI
Private Sub UpdateUI(ByVal message As String)
If Me.InvokeRequired then
Me.Invoke(updateMyUI, message)
Else
txtLongest.Text = message
End If
End Sub
Private Sub mythreadmethod1()
Dim sw As New Stopwatch()
sw.Start()
For i As Integer = 0 To 1000
Next
sw.Stop()
Dim ExecutionTimeTaken As String = String.Format("Minutes :{0}" & vbLf & "Seconds :{1}" & vbLf & " Mili seconds :{2}", sw.Elapsed.Minutes, sw.Elapsed.Seconds, sw.Elapsed.TotalMilliseconds)
UpdateUI(ExecutionTimeTaken)
End Sub