''' <summary> ''' async read on secondary thread ''' </summary> Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, _ ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _ Handles SerialPort1.DataReceived If comOpen Then Try readBuffer = SerialPort1.ReadLine() 'data to UI thread Me.Invoke(New EventHandler(AddressOf DoUpdate)) Catch ex As Exception MsgBox("read " & ex.Message) End Try End If End Sub
''' <summary> ''' update received string in UI ''' </summary> Public Sub DoUpdate(ByVal sender As Object, ByVal e As System.EventArgs) tbRx.Text = readBuffer End Sub