Exeptions

Hi,

I am writing a communication program for the Serial port (COM1).
This works fine for sending data over the comport (SerialPort1.Write(TextBox.Text)
e.t.c..

For receiving data from the comport i wrote the following code:

Private Sub SerialPort1_DataReceived(ByVal SENDER As System.Object.......)
.......
RxTextBox.Text = (SerialPort1.ReadingExisting)
.......

Now a get the next message:
InvalidOperationExeptionwas unhandled
Cross-thread operation not valid:Control "RxTextBox" accessed from a thread
other than the thread it was created on.

Could anyone tell me wat this is , and how to get it right?

Many thanks

Peter

[668 byte] By [tjerk] at [2008-1-25]
# 1
Hi Peter,

This means that you cannot access the TextBox to update the Text property from a thread other than the UI thread (that created your TextBox).

To update the Text property, you're going to need to marshal the call back to the UI thread and then, once there, update the Text property.

For more information, see How to: Manipulate Controls from Threads.

Hope that helps!

-Paul

PaulLaudeman at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic Language...