// TODO: remove this? #endregion #region Start - Stop Monitoring public void StartMonitoring() { try { Watcher.Query = WqlQuery; Watcher.EventArrived += new EventArrivedEventHandler(watcherEventHandler); Watcher.Start(); State = MonitoringItemState.Running; } catch (ManagementException e) { State = MonitoringItemState.Undefined; throw e; } catch (System.Runtime.InteropServices.COMException e) { State = MonitoringItemState.Undefined; if ((uint)e.ErrorCode >= 0x80041001 | (uint)e.ErrorCode <= 0x80044031) { // TODO: Add code to return XML documentation // Summary field for the corresponding // System.Management.ManagementStatus enum throw new ManagementException( ((ManagementStatus)e.ErrorCode).ToString()); } } }
protected virtual void Dispose(bool disposing) { if (disposing) { Watcher.Stop(); Watcher.EventArrived -= watcherEventHandler; State = MonitoringItemState.Stopped; } }
public void StopMonitoring() { try { Watcher.Stop(); Watcher.EventArrived -= watcherEventHandler; State = MonitoringItemState.Stopped; } catch { State = MonitoringItemState.Undefined; } }