示例#1
0
文件: WMI.cs 项目: gam4er/BulkReq
 static CimAsyncMultipleResults <CimInstance> AsyncListRunningProcesses(CimSession session)
 {
     if (!HideToConsole)
     {
         Console.WriteLine("{0,-10} {1,-10} {2,4:1}", "PID", "PPID", "Name");
     }
     return(session.QueryInstancesAsync(@"root\cimv2", "WQL", "SELECT * FROM Win32_Process"));
 }
 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);
     }
 }