Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Foo(ByVal sender As Object, ByVal e As EventArgs)
- Dim Options As New ConnectionOptions With {
- .Username = "DOMAINUserName",
- .Password = "Password1"
- }
- Dim Scope As New ManagementScope("\HVSERVER01RootVirtualizationV2", Options)
- Dim Query As New EventQuery(
- "SELECT *
- FROM __InstanceModificationEvent
- WHERE TargetInstance ISA 'Msvm_ConcreteJob'"
- )
- Watcher = New ManagementEventWatcher(Scope, Query)
- Dim TimeSpan As New TimeSpan(0, 0, 1)
- Watcher.Options = New EventWatcherOptions(Nothing, TimeSpan, 1)
- ' When a new event arrives, call sub to handle it
- AddHandler Watcher.EventArrived, AddressOf DoStuff
- ' Start listening
- Watcher.Start()
- End Sub
- Private Sub DoStuff(ByVal sender As Object, ByVal e As EventArgs)
- DataGridView1.Invoke(Sub()
- ' Update DataGridView1 for the VM that is being modified
- ' Only problem is... how to correlate the VM object to this job?
- End Sub)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement