public static void SubscribeASync(CimSession cimSession, string cimNamespace)
        {
            try
            {
                string query = QueryInstanceCore();

                //Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Press <Enter> to abort the subscription");
                //Console.ResetColor();

                IObservable <CimSubscriptionResult>  queryInstances = cimSession.SubscribeAsync(cimNamespace, "WQL", query, GetOperationOptions());
                TestObserver <CimSubscriptionResult> observer       = new TestObserver <CimSubscriptionResult>();
                IDisposable disposeAble = queryInstances.Subscribe(observer);

                Console.ReadLine();

                disposeAble.Dispose();
            }
            catch (CimException ex)
            {
                PrintCimException(ex);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        private void SubscribeCimSessionEvent(string namespaceName, string query)
        {
            IObservable <CimSubscriptionResult> queryInstances = CimSession.SubscribeAsync(namespaceName, "WQL", query);
            var observer = new MMIObserver <CimSubscriptionResult>();

            TouchScreenDisposeAble = queryInstances.Subscribe(observer);
        }
Exemple #3
0
        public void Initialize()
        {
            _cimWatcherStatus = CimWatcherStatus.Default;
            _myLock           = new object();

            _cimSession = CimSession
                          .Create(_computerName);

            _cimObservable = _cimSession
                             .SubscribeAsync(_nameSpace, _queryDialect, _queryExpression);
        }
        public IValueChangedNotify SubscribeBrightnessEvent()
        {
            string namespaceName = "root\\WMI";
            string query         = "SELECT Brightness from WmiMonitorBrightnessEvent";

            IObservable <CimSubscriptionResult> queryInstances = CimSession.SubscribeAsync(namespaceName, "WQL", query);
            var observer = new MMIObserver <CimSubscriptionResult>();

            TouchScreenDisposeAble = queryInstances.Subscribe(observer);
            return(observer);
        }