What's so unusual? You call a blocking operation with timeout, but something from the other side of the serial cable don't send you anything. :-)
You can check up the buffer if it has data and don't read when there is no data, use
System.IO.Ports.SerialPort.BytesToRead
and use longer timeout, use
System.IO.Ports.SerialPort.ReadTimeout
.
See
http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.aspx[
^].
Now, as you're dealing with blocking calls, do you use a separate thread for this purpose? You should. Your best option is creating a separate thread which unconditionally reads everything and push data to other thread when something happen. Read operation is blocking, so you don't want to block you main thread.
For appropriate inter-thread communication read my short Tips/Tricks article
Simple Blocking Queue for Thread Communication and Inter-thread Invocation[
^].
To notify UI thread, you need to use the method
Invoke
or
BeginInvoke
of
System.Windows.Threading.Dispatcher
(for both Forms or WPF) or
System.Windows.Forms.Control
(Forms only).
You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[
^],
Problem with Treeview Scanner And MD5[
^].
See also my collection of links to my past answers on threading:
How to get a keydown event to operate on a different thread in vb.net[
^],
Control events not firing after enable disable + multithreading[
^].
—SA