now that ive changed my code around i can no longer change a control on my main form from a class thats being run on a different thread.
my onload event has this:
which runs the wc.findmyport sub in the class2 class. i tried using this:Code:WC = New Class2 ThreadingPool.QueueUserWorkItem(AddressOf WC.FindMyPort)
but its not longer working. i assume because im working with two different classes. ive tried changing everything from private to public. what i want to do is change a label's text on my main form from my class2 class being run on a seperate threadCode:Private Delegate Function GetControlTextInvoker(ByVal ctl As Control) As String Private Function GetControlText(ByVal ctl As Control) As String Dim text As String If ctl.InvokeRequired Then text = CStr(ctl.Invoke(New GetControlTextInvoker(AddressOf GetControlText), ctl)) Else text = ctl.Text End If Return textEnd Function
th




Reply With Quote