public void Initialize() { _cimWatcherStatus = CimWatcherStatus.Default; _myLock = new object(); _cimSession = CimSession .Create(_computerName); _cimObservable = _cimSession .SubscribeAsync(_nameSpace, _queryDialect, _queryExpression); }
public void Stop() { lock (_myLock) { if (_isDisposed) { throw new ObjectDisposedException(nameof(ManagementEventWatcher)); } if (_cimWatcherStatus != CimWatcherStatus.Started) { return; } _subscription?.Dispose(); _cimWatcherStatus = CimWatcherStatus.Stopped; } }
public void Start() { lock (_myLock) { if (_isDisposed) { throw new ObjectDisposedException(nameof(ManagementEventWatcher)); } if (_cimWatcherStatus != CimWatcherStatus.Default && _cimWatcherStatus != CimWatcherStatus.Stopped) { return; } _subscription = _cimObservable.Subscribe(this); _cimWatcherStatus = CimWatcherStatus.Started; } }