VB.NET Serial communications and multithreading
Posted on 2010-08-19
I have an application that uses the "On Datareceived" event for serial component (VB.NET 2010).
While the program is receiving data from the serial port, if I attempt to move the form while it is receiving I generate a communications error (the reply timer I set up times out).
The program sends a line of text and sets a reply timeout. After timeout, if data is available then it is processed, if not then coms error is indicated.
Though the data return happens in around 30ms (it is single ACK byte), I need to set timer to over 100ms to avoid the movement of the form from interfering with the receive process, but this makes the download very slow.
Is there some way to stop the user being able to move the form around during reception
Some sort of threading arrangement to prevent form movement effecting serial data reception timing
A better way to receive data (I tried to set a longer reply timeout and then inside the Data Received routine setting the timer interval to low value once data arrives so it does not need to wait for the entire timeout period but was not successful.
Thanks in advance for any help or code snippet that shows a better method of handling incoming data.