VB101SamplesBCL2 Using The serial PORt..
Well the time has come to start messing with the serialport...AHHHHH..
Downloaded the VB101SamplesBCL2 and loaded up the Usingtheserialport project.. Answered a lot of question right off the bat, BUT... I seem to have some strangeness going on.
I built the project and moved the exe to a win98 test machine I use. All runs fine on that machine. I run the project in the enviroment on the XP machine and in the
serialPort_DataReceived 'event' I get InvalidOperationException... cross-thread calls
Begin Post::
System.InvalidOperationException was unhandled
Message="Cross-thread operation not valid: Control 'textBox2' accessed from a thread other than the thread it was created on."
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.set_WindowText(String value)
at System.Windows.Forms.TextBoxBase.set_WindowText(String value)
at System.Windows.Forms.Control.set_Text(String value)
at System.Windows.Forms.TextBoxBase.set_Text(String value)
at System.Windows.Forms.TextBox.set_Text(String value)
at UsingTheSerialPort.Form1.serialPort_DataReceived(Object sender, SerialDataReceivedEventArgs e) in C:\Documents and Settings\Jim\My Documents\MSDN\VB101SamplesBCL2\UsingTheSerialPort\Form1.vb:line 40
at System.IO.Ports.SerialPort.CatchReceivedEvents(Object src, SerialDataReceivedEventArgs e)
at System.IO.Ports.SerialStream.EventLoopRunner.CallReceiveEvents(Object state)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
ENd Post::
Nice sample? Works compiled on a Win98 OK.. Well At least it doesn't crash..
Will run the exe on the xp machine and look for solutions for cross thread calls etc..
Just wondering if anyone else had seen this.. I did try to do a search here but found nothing
st..

