please help me ..
if i close the serial port , the application has hangs ..
script:
if i close the serial port , the application has hangs ..
script:
Private Sub cmdDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDisconnect.Click RemoveHandler SerialPort1.DataReceived, AddressOf DoUpdate System.Threading.Thread.Sleep(1000) If SerialPort1.IsOpen Then SerialPort1.Close() End Sub Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, _ ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _ Handles SerialPort1.DataReceived If ComOpen Then Try byteEnd = SerialPort1.NewLine.ToCharArray bacabuffer = SerialPort1.ReadLine() Me.Invoke(New EventHandler(AddressOf DoUpdate)) Catch ex As Exception MsgBox("read" & ex.Message) End Try End If End Sub Public Sub DoUpdate(ByVal sender As Object, ByVal e As System.EventArgs) TextBox1.Text = bacabuffer End Sub
Last edited by a moderator: