Threading error with 2005 com port

G

Gary Kahrau

I hope this is a simple question for threading people. VB 2005 Beta2
has a new SerialPort control.

I can read the data that I want just fine. However when I try to
display the text, I get a threading error. See event code and error
message below.
How do I get around this threading error???

Private Sub SerialPort1_DataReceived1(ByVal sender As Object,
ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles
SerialPort1.DataReceived
txt = SerialPort1.ReadLine
lbData.text = txt ' <--- Get thread error here.
End Sub


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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top