PORTS Forum

Ports and Interfaces => Serial Ports => Topic started by: GlennP on October 26, 2011, 05:31:11 am

Title: Accessing a serial port from more one form?
Post by: GlennP on October 26, 2011, 05:31:11 am
Hi all,
I am writing an app to emmulate a PSION, and have neatly created a front end in C# that relies on multiple forms I now need to send some commands via a serial port when I try I get       
 
"Cross-thread operation not valid: Control 'richTextBox1' accessed from a thread other than the thread it was created on."

I take that to mean I can't open the port on Form1 and talk to via Form2, is the correct method then to create the command string pass it back to Form1 and then pass the data to Form2 as a string?

Thanks
Glenn
Title: Re: Accessing a serial port from more one form?
Post by: Jan Axelson on October 26, 2011, 11:03:05 am
Use a delegate. See my Com Port Terminal example or do a web search on the error message.

http://www.lvr.com/serport.htm#my_example_code

Jan
Title: Re: Accessing a serial port from more one form?
Post by: GlennP on October 27, 2011, 04:30:59 am
Thanks Jan, panic then remembered how I got over this problem last time, run the exe and not the debug! I will when I have chance look at the delegate method as that is probably the correct method!

Glenn