Imports System
Imports System.Management
Public Class EventWatcherPolling
Public Overloads Shared Function Main(ByVal args() As String) As Integer
Dim query As String
query = "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance isa ""Win32_Process"""
Dim eventOptions As New EventWatcherOptions
eventOptions.Timeout = System.TimeSpan.MaxValue
Dim watcher As New ManagementEventWatcher("root\CIMV2", query, eventOptions)
Dim e As ManagementBaseObject = watcher.WaitForNextEvent()
watcher.Stop()
Return 0
End Function
End Class