private void stopReading() { if (_serialPort != null) { try { _serialPort.DataReceived -= new System.IO.Ports.SerialDataReceivedEventHandler(_serialPort_DataReceived); while (_reading) { System.Threading.Thread.Sleep(100); } _serialPort.Dispose(); } catch { } _serialPort = null; if (_activeNotification != null) { _activeNotification.Stop -= new EventHandler <EventArgs>(_activeNotification_Stop); _activeNotification.Visible = false; _activeNotification = null; } } }
private void startReading() { if (_serialPort == null) { try { _hasGPRMC = false; _serialPort = new System.IO.Ports.SerialPort(PluginSettings.Instance.ComPort, PluginSettings.Instance.BaudRate, (System.IO.Ports.Parity)Enum.Parse(typeof(System.IO.Ports.Parity), PluginSettings.Instance.Parity), PluginSettings.Instance.Databits, (System.IO.Ports.StopBits)Enum.Parse(typeof(System.IO.Ports.StopBits), PluginSettings.Instance.StopBits)); _serialPort.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(_serialPort_DataReceived); _serialPort.Open(); _activeNotification = new ActiveNotification(Core); _activeNotification.Stop += new EventHandler <EventArgs>(_activeNotification_Stop); this.OnNotification(_activeNotification); } catch { _serialPort = null; } } }
private void startReading() { if (_serialPort == null) { try { _hasGPRMC = false; _serialPort = new System.IO.Ports.SerialPort(Properties.Settings.Default.ComPort, Properties.Settings.Default.BaudRate, (System.IO.Ports.Parity)Enum.Parse(typeof(System.IO.Ports.Parity), Properties.Settings.Default.Parity), Properties.Settings.Default.Databits, (System.IO.Ports.StopBits)Enum.Parse(typeof(System.IO.Ports.StopBits), Properties.Settings.Default.StopBits)); _serialPort.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(_serialPort_DataReceived); _serialPort.Open(); _activeNotification = new ActiveNotification(Core); _activeNotification.Stop += new EventHandler<EventArgs>(_activeNotification_Stop); this.OnNotification(_activeNotification); } catch { _serialPort = null; } } }
private void stopReading() { if (_serialPort != null) { try { _serialPort.DataReceived -= new System.IO.Ports.SerialDataReceivedEventHandler(_serialPort_DataReceived); while (_reading) { System.Threading.Thread.Sleep(100); } _serialPort.Dispose(); } catch { } _serialPort = null; if (_activeNotification != null) { _activeNotification.Stop -= new EventHandler<EventArgs>(_activeNotification_Stop); _activeNotification.Visible = false; _activeNotification = null; } } }