コード例 #1
0
        public void Initialize()
        {
            _cimWatcherStatus = CimWatcherStatus.Default;
            _myLock           = new object();

            _cimSession = CimSession
                          .Create(_computerName);

            _cimObservable = _cimSession
                             .SubscribeAsync(_nameSpace, _queryDialect, _queryExpression);
        }
コード例 #2
0
        public void Stop()
        {
            lock (_myLock)
            {
                if (_isDisposed)
                {
                    throw new ObjectDisposedException(nameof(ManagementEventWatcher));
                }

                if (_cimWatcherStatus != CimWatcherStatus.Started)
                {
                    return;
                }

                _subscription?.Dispose();

                _cimWatcherStatus = CimWatcherStatus.Stopped;
            }
        }
コード例 #3
0
        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;
            }
        }