L
Lou
I have a class that uses the serial port class
Private SerialPort as New SerialPort
When I receive the asyncronous serial port response it appears that data is
on a different thread than my UI.
When I try to raise an event in my class my frmMain doesn't get the
callback. i think this is a threading issue.
Question is how do I get the serial port response from my vb class to my
main form.
Also when I send data the event in my send never gets raised back to my main
form.
Again this appears to be a threading issue and I have no solution. I have
been at this for days. Arghh.
Here is my send code. Notice the "RaiseEvent", well it nevrs gets received
by my main form that has this class defind withEvents.
Public Function SendData(ByVal sData As String) As Boolean '
Dim Bytes() As Byte = System.Text.Encoding.Default.GetBytes(sData)
If mProtocol = eProtocolType.Serial Then
Try
If SerialPort.IsOpen = False Then OpenSerialPort(mComPort)
' Write a line to the serial port
SerialPort.Write(Bytes, 0, (Bytes.Length - 1))
RaiseEvent Rs232DataSent(sData) 'I GET HERE BUT THE DATA GOES INTO LA LA
LAND!!!!
Catch ex As System.Exception
MessageBox.Show(ex.Message)
End Try
End If
End Sub
Private SerialPort as New SerialPort
When I receive the asyncronous serial port response it appears that data is
on a different thread than my UI.
When I try to raise an event in my class my frmMain doesn't get the
callback. i think this is a threading issue.
Question is how do I get the serial port response from my vb class to my
main form.
Also when I send data the event in my send never gets raised back to my main
form.
Again this appears to be a threading issue and I have no solution. I have
been at this for days. Arghh.
Here is my send code. Notice the "RaiseEvent", well it nevrs gets received
by my main form that has this class defind withEvents.
Public Function SendData(ByVal sData As String) As Boolean '
Dim Bytes() As Byte = System.Text.Encoding.Default.GetBytes(sData)
If mProtocol = eProtocolType.Serial Then
Try
If SerialPort.IsOpen = False Then OpenSerialPort(mComPort)
' Write a line to the serial port
SerialPort.Write(Bytes, 0, (Bytes.Length - 1))
RaiseEvent Rs232DataSent(sData) 'I GET HERE BUT THE DATA GOES INTO LA LA
LAND!!!!
Catch ex As System.Exception
MessageBox.Show(ex.Message)
End Try
End If
End Sub