Can anyone please tell me how to fix this? I keep getting a "Cross-thread operation not valid error." I feel like I need to somehow add a public event within the separate thread, but don't know how. Thanks
Public Class Form2
Public WithEvents _tasks As New Tasks
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
_tasks.StartThread()
End Sub
Public Sub task1(msg As String) Handles _tasks.DoTask1
TextBox1.Text &= msg
End Sub
End Class
Public Class Tasks
Public Event DoTask1(msg As String)
Public _thread As New Thread(AddressOf TasksThread)
Public Sub StartThread()
_thread.Start()
End Sub
Public Sub TasksThread()
Do
RaiseEvent DoTask1("1")
Thread.sleep(1000)
Loop While True
End Sub
End Class