2008년 7월 20일 일요일

VB.net 에서 시리얼 통신 에러 발생

출차 : Naver Cafe, I Love Visual Basic

시리얼 통신 및 스레드에 값을 객체로 넘길 때 발생하는

invoke error 해결 방법

Dim strRFID as string=""

Private Delegate Sub MyDelegate()

Private Sub barComm_dataReceivced(Byval sender as System.Object, _
 Byval e As System.IO.Ports.SerialDataReceivedEventArgs) _
 Handles barComm.DataRecevced

Try
 strRFID = DirectCast(sender, IO.Ports.SerialPort).ReadExisting()
 Dim mydlg as Mydelegate
 mydlog = New MyDelegate(AddressOf inText)
 Me.TxtReIssueRFID.Invoke(myDlg)
Catch ex As Exception
 MessageBox.Show(ex.Message)
End Try
End Sub

Private Sub inText()
 Me.txtReIssueRFID.TextVAlue = strRFID
End Sub