title: Confused about WMI in .NET synchronous/asynchronous execution and results
body: <p>I am trying to load the Hyper-V system definition from an export on a Windows 8 system using WMI. So far, I have this:</p>
  
  <pre><code>var managementScope = new ManagementScope(@"root\virtualization\v2");
  var invokeMethodOptions = new InvokeMethodOptions();
  invokeMethodOptions.Timeout = new TimeSpan(0, 0, 10);
  using (var managementService = WmiUtilities.GetVirtualMachineManagementService(managementScope)) {
      var inParameters = managementService.GetMethodParameters(@"ImportSystemDefinition");
      inParameters["SystemDefinitionFile"] = filePath;
      inParameters["SnapshotFolder"] = snapshotPath;
      inParameters["GenerateNewSystemIdentifier"] = false;
      ManagementBaseObject outParameters = managementService.InvokeMethod(@"ImportSystemDefinition", inParameters, invokeMethodOptions);
      foreach (var value in outParameters.Properties) {
          Console.WriteLine("{0}: {1}", value.Name, value.Value);
      }
      return (ManagementBaseObject) outParameters["ImportedSystem"];
  }
  </code></pre>
  
  <p>When I run this, the return code is <code>4096</code>, indicating a job has started successfully, and I get a job value back - for example:</p>
  
  <pre><code>ImportedSystem: 
  Job: \\COREI7\root\virtualization\v2:Msvm_ConcreteJob.InstanceID="B1DC90B6-14A1-42C0-924E-225660E6EC98"
  ReturnValue: 4096
  </code></pre>
  
  <p>I have the following questions:</p>
  
  <ol>
  <li>Is it possible to execute this method synchronously? How can I tell that? The MSDN documentation at <a href="http://msdn.microsoft.com/en-us/library/hh850082(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/hh850082(v=vs.85).aspx</a> suggests it is possible ("If the operation completes synchronously") but I don't see how. My guess is this is a general WMI question about how to execute methods synchronously, which I can't seem to find how to do.</li>
  <li>If I am force to do asynchronous, how to I watch that specific job? Everything I'm finding is on watching process events or event log events, but those both seem to be specific WQL events I'm targeting and not general job events.</li>
  </ol>
  
  <p>I apologize if these questions are too basic - I'm just having no luck finding the answers.</p>
  
  <p>Thanks!</p>
  
  <p>[Edit] I'm looking into adding a <code>ManagementOperationObserver</code> to tell me when it's done, although it's not clear why I need to force it asynchronous when it seems to be doing that anyway.</p>