public void Start()
 {
     try
     {
         watcher.Start();
         IrssLog.Info("Started Hardware Monitoring. Waiting for an event...");
     }
     catch (ManagementException err)
     {
         IrssLog.Error("An error occurred while trying to receive an event: " + err.Message);
     }
 }
 public void Stop()
 {
     try
     {
         watcher.Stop();
         IrssLog.Info("Stopped Hardware Monitoring.");
     }
     catch (ManagementException err)
     {
         IrssLog.Error("An error occurred while trying to stop hardware monitoring: " + err.Message);
     }
 }
        public HardwareMonitor()
        {
            lastEvent             = HardwareEventType.ConfigurationChanged;
            lastHardwareEventTime = DateTime.MinValue;

            try
            {
                WqlEventQuery query = new WqlEventQuery(
                    "SELECT * FROM Win32_DeviceChangeEvent");

                watcher = new ManagementEventWatcher(query);

                watcher.EventArrived +=
                    new EventArrivedEventHandler(
                        HandleEvent);
            }
            catch (ManagementException err)
            {
                IrssLog.Error("An error occurred while trying to receive an event: " + err.Message);
            }
        }