private void CreateHandler() { var port = ComManager.GetComPort(); panelControls.Enabled = !string.IsNullOrWhiteSpace(port); if (string.IsNullOrWhiteSpace(port)) { MessageBox.Show(@"COM port not found!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { statusCom.Text = port; _comHandler = new ComHandler(port); _comHandler.DataReceived += _comHandler_DataReceived; _comHandler.Start(); } UpdateOnButton(); }
private void DestroyHandler() { _comHandler?.Off(); _comHandler?.Stop(); _comHandler = null; }