G
Guest
Hello,
I had originally posted this in the winforms.controls discussion, forgive
the double post, Here is where I need help...
I have been porting some VB6 to VB2005 and here is the issue with the serial
port.
I am looking to update controls on the main form (textbox, listbox, etc)
when a call comes in. I can retrieve the ring status, caller-id etc, but
when I go to update a textbox, I receive a threading exception issue. As I
understand it, the "datareceived" event is raised on a second thread so I can
not directly update controls on the main form or (first thread) without using
INVOKE. My question is How do I do that?
Private Sub m_CommPort_DataReceived(ByVal sender As Object, _
ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles
m_CommPort.DataReceived
Dim strModemRecBuffer As String = ""
strModemRecBuffer = m_CommPort.ReadExisting
....
....Extract the data from the string
....
....I realize this next line is the (Thread exception) since the control is
on the main form.
txtIncomingCall.text = strModemRecBuffer(index)
So how do I use invoke to update the controls on the first thread?
Any help would be appreciated Thanks,
SatCom
I had originally posted this in the winforms.controls discussion, forgive
the double post, Here is where I need help...
I have been porting some VB6 to VB2005 and here is the issue with the serial
port.
I am looking to update controls on the main form (textbox, listbox, etc)
when a call comes in. I can retrieve the ring status, caller-id etc, but
when I go to update a textbox, I receive a threading exception issue. As I
understand it, the "datareceived" event is raised on a second thread so I can
not directly update controls on the main form or (first thread) without using
INVOKE. My question is How do I do that?
Private Sub m_CommPort_DataReceived(ByVal sender As Object, _
ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles
m_CommPort.DataReceived
Dim strModemRecBuffer As String = ""
strModemRecBuffer = m_CommPort.ReadExisting
....
....Extract the data from the string
....
....I realize this next line is the (Thread exception) since the control is
on the main form.
txtIncomingCall.text = strModemRecBuffer(index)
So how do I use invoke to update the controls on the first thread?
Any help would be appreciated Thanks,
SatCom