title: Cross Thread invoke from class ? Confused - vb.net
body: <p>maybe I am being stooped... but the fact is that I am a bit of a n00b concerning threading...</p>
  
  <p>I am making use of a serial port in a class. I am raising an event from that class to my form calling the class. Event contains data received... </p>
  
  <p>I wish to simply populate a textbox from the raised event.</p>
  
  <p>Now I am not specifically creating a seperate thread, but I get the normal crossthreading error when trying to update my textbox on the UI, so my assumption is that the serial port and its internal methods probably creates its own threads...</p>
  
  <p>Regardless, I am a bit confused as to how to properly implement an invoke, from my main form, pointing to the thread in the instantiated class...</p>
  
  <p>I hope this makes sense...</p>
  
  <p><code>
   Dim WithEvents tmpRS232 As New clsRS232</p>
  
  <pre><code>Private Sub but_txt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles but_txt.Click
      tmpRS232.Set_com_port("COM8", 38400)
      tmpRS232.Transmit_data(txt_tx.Text)
  End Sub
  
  Private Sub tmprs232_rx_data_returned(ByVal str_data As String) Handles tmpRS232.rx_data_returned
      txt_rx.Text = str_data 'Cross threading error
      MsgBox(str_data) 'Fires without errors
  End Sub
  </code></pre>
  
  <p></code></p>
  
  <p>Can someone please provide a code example based on this code?</p>
  
  <p>thanks.</p>