problem with serial port and cross threads
-
Hello Everyone. i have done an application in vs2005 who reads some input from a barcode scanner, displays the string read by the barcode on a textbox, updates a database and shows the results on some datagridviews. the barcode scanner is attached to a COM port. my problem is that when i attempt to process the data read (using the SerialPort.DataReceived event), i get a cross thread invalid operation exception (it says it can't access the textbox, because it's a different thread from the one who created it). if i try to set the control.CheckForIllegalCrossThreadCalls property to false, i can write text on the textbox, but my application locks up as it tries to do other things as refreshing datagrids or showing other forms. Please understand i have very little knowledge of VB.NET 2005. is there a simple way to solve this? Thanks in advance.
~~~ From Milano to The Hague, easy as it goes ~~~
-
Hello Everyone. i have done an application in vs2005 who reads some input from a barcode scanner, displays the string read by the barcode on a textbox, updates a database and shows the results on some datagridviews. the barcode scanner is attached to a COM port. my problem is that when i attempt to process the data read (using the SerialPort.DataReceived event), i get a cross thread invalid operation exception (it says it can't access the textbox, because it's a different thread from the one who created it). if i try to set the control.CheckForIllegalCrossThreadCalls property to false, i can write text on the textbox, but my application locks up as it tries to do other things as refreshing datagrids or showing other forms. Please understand i have very little knowledge of VB.NET 2005. is there a simple way to solve this? Thanks in advance.
~~~ From Milano to The Hague, easy as it goes ~~~