C
cj2
How do I get the threads to update the richtextbox1 on form1? This
isn't working.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
For x = 1 To 7
Dim oSession As SessionClass
Dim oThread As Thread
Try
oSession = New SessionClass
oThread = New Thread(AddressOf oSession.ThreadMain)
oThread.ApartmentState = ApartmentState.STA
oThread.Start()
Catch ex As Exception
MessageBox.Show("starting thread " & Str(x) & " failed")
End Try
Next
MessageBox.Show("end test")
End Sub
Imports System.Threading
Module Module1
Public Class SessionClass
Public Sub ThreadMain()
MyThreadCount.Increment()
System.Threading.Thread.Sleep(1000)
Form1.RichTextBox1.AppendText(vbCrLf &
MyThreadCount.ThreadCount)
MyThreadCount.Decrement()
End Sub
End Class
end module
isn't working.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
For x = 1 To 7
Dim oSession As SessionClass
Dim oThread As Thread
Try
oSession = New SessionClass
oThread = New Thread(AddressOf oSession.ThreadMain)
oThread.ApartmentState = ApartmentState.STA
oThread.Start()
Catch ex As Exception
MessageBox.Show("starting thread " & Str(x) & " failed")
End Try
Next
MessageBox.Show("end test")
End Sub
Imports System.Threading
Module Module1
Public Class SessionClass
Public Sub ThreadMain()
MyThreadCount.Increment()
System.Threading.Thread.Sleep(1000)
Form1.RichTextBox1.AppendText(vbCrLf &
MyThreadCount.ThreadCount)
MyThreadCount.Decrement()
End Sub
End Class
end module