none
我想问问出现这个error是代表着什么意思 RRS feed

  • 问题

  • Cross-thread operation not valid: Control 'TextBox1' accessed from a thread other than the thread it was created on.

    我 develop 着一个barcode scanner 的program

     Private dataIn As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load    

    SerialPort.PortName = "COM1"
            SerialPort.BaudRate = CInt("9600")
            SerialPort.Parity = Parity.None
            SerialPort.StopBits = StopBits.One
            SerialPort.Handshake = Handshake.None
            SerialPort.Open()
            SerialPort.ReadTimeout = 200

            If SerialPort.IsOpen Then
                TextBox1.Text = ""
            End If

    end sub

        Private Sub SerialPort_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceived

            dataIn = SerialPort.ReadExisting
            TextBox1.AppendText(dataIn & vbNewLine) 我在这里get 到这个error 不知是代表什么意义(Cross-thread operation not valid: Control 'TextBox1' accessed from a thread other than the thread it was created on.)
        End Sub

    求解

    谢谢

    2019年11月15日 3:50

全部回复