/// <summary> /// Stops the serial port monitor. /// </summary> private void StopSerialPortMonitor() { DebugOutput("IOService: StopSerialPortMonitor"); var systemPowerManagement = PortNotifier as ISystemPowerManagement; if (systemPowerManagement != null) { systemPowerManagement.SystemDidPowerOn -= HandleSystemDidPowerOn; systemPowerManagement.SystemWillPowerOff -= HandleSystemWillPowerOff; systemPowerManagement.SystemWillSleep -= HandleSystemWillSleep; } PortNotifier.Stop(); PortNotifier = null; }
/// <summary> /// Starts the serial port monitor. /// </summary> private void StartSerialPortMonitor() { DebugOutput("IOService: StartSerialPortMonitor"); PortNotifier = CreatePortNotifier(); var systemPowerManagement = PortNotifier as ISystemPowerManagement; if (systemPowerManagement != null) { systemPowerManagement.SystemWillSleep += HandleSystemWillSleep; systemPowerManagement.SystemWillPowerOff += HandleSystemWillPowerOff; systemPowerManagement.SystemDidPowerOn += HandleSystemDidPowerOn; } PortNotifier.Start(); }
private void RunUI() { try { // Init stuff // Need to do this from the same thread as Application.Run() will run from... PortNotifier.Init(); mNotifyIcon = new UI.NotifyIcon(Properties.Resources.NotifyIcon); // FIXME - NOT thread safe updateNotificationStatus(); Application.Run(mApplicationContext); // Signal quit mRunning = false; } catch (Exception e) { Logging.Log.Exception(e); } }
private void PortAdded(object sender, PortNotifier.PortAddedEventArgs args) { if (args.Port == mPort && !IsConnected) { // Trigger a retry to connect to the port mPortEvent.Set(); } }