I have a serial connection to a remote machine and i'm developing a windows form using vb.net in order to gather some infos.
So as u can see in the code below i'm waiting until i receive the full string ( length 4, # as separator ) to change some textboxes text.
Dim ReceivedTextSeries As String = vbNullString
Private Sub ReceivedText(ByVal [text] As String)
If TextBoxConsola.InvokeRequired Then
Dim x As New SetTextCallBlack(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
ReceivedTextSeries &= [text]
JustTesting()
Else
TextBoxConsolaReceived.Text &= [text]
ReceivedTextSeries &= [text]
JustTesting()
End If
End Sub
Sub JustTesting()
Dim Series() As String = ReceivedTextSeries.Split("#")
If Series.Length = 4 Then
TextBox1.Text = Series(0)
TextBox2.Text = Series(2)
End If
End Sub
But i'm getting an error saying that multithreading isn't allowed..
The operation between threads is not valid: Control 'TextBox1' accessed from a thread other than the thread where it was created.
How can i manage this now? I've tried to add event handlers to avoid this but without success..