I know the DataReceived event is fired on a background thread. How do I tell the GUI thread to show the data in the event handler?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This code assumes you have already added a form-level
SerialPortobject with theport_DataReceivedmethod attached to itsDataReceivedevent, and that you have a label namedlabel1on your form.I’m not 100% certain about the code that converts the bytes available in the port to a string, as I have not run this with a live serial port collecting data. But this code will allow you to display the received data regardless of whether the event is on a different thread or not.