Private Sub SelectdbcFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectdbcFileToolStripMenuItem.Click Me.TreeView1.Nodes.Clear() Me.SignalCollection = Settings.readDBCFile() Me.TreeView1.Sort() canlibCLSNET.Canlib.canInitializeLibrary() do hnd0 = canlibCLSNET.Canlib.canOpenChannel(0, canlibCLSNET.Canlib.canOPEN_OVERRIDE_EXCLUSIVE) If hnd0 >= 0 Then canlibCLSNET.Canlib.canSetBusParams(hnd0, canlibCLSNET.Canlib.BAUD_500K, 0, 0, 0, 0, 0) End If hnd1 = canlibCLSNET.Canlib.canOpenChannel(1, canlibCLSNET.Canlib.canOPEN_OVERRIDE_EXCLUSIVE) If hnd1 >= 0 Then canlibCLSNET.Canlib.canSetBusParams(hnd1, canlibCLSNET.Canlib.BAUD_500K, 0, 0, 0, 0, 0) End If If (hnd0 < 0 Or hnd1 < 0) Then Dim result As DialogResult = MessageBox.Show("Unable to Open CAN Channels. Retry?", _ "Connection Error...", _ MessageBoxButtons.YesNo, _ MessageBoxIcon.Warning) If result = System.Windows.Forms.DialogResult.No Then canlibCLSNET.Canlib.canClose(hnd0) canlibCLSNET.Canlib.canClose(hnd1) Me.Close() 'I want to cancel the event here!" End If End If Loop While (hnd0 < 0 Or hnd1 < 0) If canlibCLSNET.Canlib.canBusOn(hnd0) <> CanlibBase.canStatus.canOK Or canlibCLSNET.Canlib.canBusOn(hnd1) <> CanlibBase.canStatus.canOK Then Console.WriteLine("Error: Cannot open both channels") End If While (canlibCLSNET.Canlib.canReadSync(hnd1, 100)) End While trd0 = New Threading.Thread(AddressOf tsk0) trd0.IsBackground = True trd0.Start() trd1 = New Threading.Thread(AddressOf tsk1) trd1.IsBackground = True trd1.Start() RadioButton1.Enabled = True RadioButton2.Enabled = True RadioButton1.Checked = False TextBox1.Enabled = False RadioButton2.Enabled = True TextBox2.Enabled = True RadioButton2.Checked = True Button1.Enabled = False Button3.Enabled = False End Sub