Advertisement
Guest User

Untitled

a guest
Apr 17th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. Private Sub Foo(ByVal sender As Object, ByVal e As EventArgs)
  2. Dim Options As New ConnectionOptions With {
  3. .Username = "DOMAINUserName",
  4. .Password = "Password1"
  5. }
  6.  
  7. Dim Scope As New ManagementScope("\HVSERVER01RootVirtualizationV2", Options)
  8. Dim Query As New EventQuery(
  9. "SELECT *
  10. FROM __InstanceModificationEvent
  11. WHERE TargetInstance ISA 'Msvm_ConcreteJob'"
  12. )
  13.  
  14. Watcher = New ManagementEventWatcher(Scope, Query)
  15. Dim TimeSpan As New TimeSpan(0, 0, 1)
  16. Watcher.Options = New EventWatcherOptions(Nothing, TimeSpan, 1)
  17.  
  18. ' When a new event arrives, call sub to handle it
  19. AddHandler Watcher.EventArrived, AddressOf DoStuff
  20.  
  21. ' Start listening
  22. Watcher.Start()
  23. End Sub
  24.  
  25. Private Sub DoStuff(ByVal sender As Object, ByVal e As EventArgs)
  26. DataGridView1.Invoke(Sub()
  27. ' Update DataGridView1 for the VM that is being modified
  28. ' Only problem is... how to correlate the VM object to this job?
  29. End Sub)
  30. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement