public static void CreateInstanceASync(CimSession cimSession, string cimNamespace, string cimClassName)
        {
            try
            {
                CimInstance createInstance = CreateInstanceCore(cimSession, cimNamespace, cimClassName);
                if (createInstance == null)
                {
                    Console.WriteLine("CreateInstance operation not performed");
                    return;
                }

                CimAsyncResult <CimInstance> enumeratedInstances = cimSession.CreateInstanceAsync(cimNamespace, createInstance, GetOperationOptions());
                TestObserver <CimInstance>   observer            = new TestObserver <CimInstance>();
                IDisposable disposeable = enumeratedInstances.Subscribe(observer);
                observer.WaitForCompletion();
            }
            catch (CimException ex)
            {
                PrintCimException(ex);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void GetInstanceASync(CimSession cimSession, string cimNamespace, string cimClassName)
        {
            // Check Arguments
            if (cimNamespace == null)
            {
                throw new ArgumentNullException("cimNamespace");
            }

            if (cimClassName == null)
            {
                throw new ArgumentNullException("cimClassName");
            }

            try
            {
                CimInstance inputInstance = GetInstanceCore(cimSession, cimNamespace, cimClassName);
                IObservable <CimInstance>  enumeratedInstances = cimSession.GetInstanceAsync(cimNamespace, inputInstance, GetOperationOptions());
                TestObserver <CimInstance> observer            = new TestObserver <CimInstance>();
                IDisposable disposeable = enumeratedInstances.Subscribe(observer);
                observer.WaitForCompletion();
            }
            catch (CimException ex)
            {
                PrintCimException(ex);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        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);
            }
        }
 public static void QueryInstanceASync(CimSession cimSession, string cimNamespace)
 {
     try
     {
         string query = QueryInstanceCore();
         IObservable <CimInstance>  queryInstances = cimSession.QueryInstancesAsync(cimNamespace, "WQL", query, GetOperationOptions());
         TestObserver <CimInstance> observer       = new TestObserver <CimInstance>();
         IDisposable disposeable = queryInstances.Subscribe(observer);
         observer.WaitForCompletion();
     }
     catch (CimException ex)
     {
         PrintCimException(ex);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        public static void EnumerateAssociatedInstanceASync(CimSession cimSession, string cimNamespace, string cimClassName)
        {
            try
            {
                string      resultClassName;
                string      associationClassName;
                CimInstance associatedInputInstance = EnumerateAssociatedInstanceCore(
                    cimSession,
                    cimNamespace,
                    cimClassName,
                    out associationClassName,
                    out resultClassName);
                if (associatedInputInstance == null)
                {
                    Console.WriteLine("EnumerateAssociatedInstanceSync operation not performed");
                    return;
                }

                IObservable <CimInstance> enumeratedInstances = cimSession.EnumerateAssociatedInstancesAsync(
                    cimNamespace,
                    associatedInputInstance,
                    associationClassName,
                    resultClassName,
                    null,
                    null,
                    GetOperationOptions());
                TestObserver <CimInstance> observer = new TestObserver <CimInstance>();
                IDisposable disposeable             = enumeratedInstances.Subscribe(observer);
                observer.WaitForCompletion();
            }
            catch (CimException ex)
            {
                PrintCimException(ex);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void InvokeMethodASync(CimSession cimSession, string cimNamespace, string cimClassName)
        {
            try
            {
                string      methodName;
                CimInstance inputInstance;
                CimMethodParametersCollection methodParameters = InvokeMethodCore(cimSession, cimNamespace, cimClassName, out methodName, out inputInstance);
                if (methodParameters == null)
                {
                    Console.WriteLine("Operation InvokeMethod not performed");
                    return;
                }

                CimAsyncMultipleResults <CimMethodResultBase> invokeParams;
                CimOperationOptions options = GetOperationOptions();
                options.EnableMethodResultStreaming = true;
                if (inputInstance == null)
                {
                    invokeParams = cimSession.InvokeMethodAsync(cimNamespace, cimClassName, methodName, methodParameters, options);
                }
                else
                {
                    invokeParams = cimSession.InvokeMethodAsync(cimNamespace, inputInstance, methodName, methodParameters, options);
                }

                TestObserver <CimMethodResultBase> observer = new TestObserver <CimMethodResultBase>();
                IDisposable disposeable = invokeParams.Subscribe(observer);
                observer.WaitForCompletion();
            }
            catch (CimException ex)
            {
                PrintCimException(ex);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }