The Invoke pattern;
Imports System.Threading
Public Class Form1
Dim MyNewThread As Thread
Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'create the thread
MyNewThread = New Thread(AddressOf MyThread.MyThreadExecute)
MyThread.ThatForm = Me
'start the thread
MyNewThread.Start()
End Sub
Public Sub SetProgress(ByVal What As String)
If InvokeRequired Then
Invoke(New Action(Of String)(AddressOf SetProgress), New Object() {What})
Return
End If
Label1.Text = What
End Sub
End Class
Module MyThread
Public ThatForm As Form1
Public Sub MyThreadExecute()
Dim i As Integer = 0
Do
i = i + 1
ThatForm.SetProgress(i)
Thread.Sleep(100)
Loop
End Sub
End Module
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]