I have a serial port app that works on a laptop but seems to freeze on the pocketpc. The incoming communication is a constant stream at 9600 baud and it looks like the "comport data received" function doesn't quit even though it is called using "me.invoke".
So my question is, why does this work on the laptop and not on the Dell Axim x51
Here is the code:
Public Class Form1
Public comport As New SerialPort()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
AddHandler comport.DataReceived, AddressOf OnSerialDataReceived
comport.DataBits = 8
comport.StopBits = StopBits.One
comport.Parity = Parity.Odd
comport.BaudRate = 9600
comport.PortName = "Com1"
comport.Open()
comport.DtrEnable = True
comport.RtsEnable = True
comport.DiscardNull = True
If comport.IsOpen = True Then
Button1.BackColor = System.Drawing.Color.Green
Else
Button1.BackColor = System.Drawing.Color.Red
End If
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
Private Sub OnSerialDataReceived(ByVal sender As Object,
ByVal args As SerialDataReceivedEventArgs)
Try
Me.Invoke(New EventHandler(AddressOf ReceiveSerialData))
Catch ex As Exception
End Try
End Sub
Sub ReceiveSerialData(ByVal s As Object, ByVal e As EventArgs)
Try
txtReceive.Text = comport.ReadTo("H")
Catch ex As Exception
Label2.Text = ex.Message.ToString
End Try
End Sub
Private Sub Send_Text()
Try
comport.WriteLine(txtSend.Text)
txtSend.Text = ""
Catch ex As Exception
Label2.Text = ex.Message.ToString()
End Try
End Sub

serial port multi thread issue
Patrick Sears
GusaMusa
The code snippet you supplied will call the ReceiveSerialData method in the UI thread. This will lock the UI until the application reads an "H" from the serial stream. You probably want to spin up a new thread or use the thread pool to read the data if you want the application to continue running.
Ryan Chapman
.NET Compact Framework
enric vives
Acco1953