Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Currently I am monitoring Memory and CPU usage using WMI. I can also detect when a new process is started by using wqlEventQuery __InstanceCreationEvent Event, along with managementeventwatcher.

Is it possible to poll CPU and Memory Usage using something similar to the instancecreationevent and managementeventwatcher and raise a event when the Memory or CPU values change?

I believe taking this approach if possible will be more cpu friendly then running the wmi query constantly.

I would usually post code showing what i have tried but honestly I am lost and need a pointer in the right direction or some information to get me started.

Thank you in advance!

What I have tried:

Public Shared Sub Process_Monitor_Start()
       Dim colMonitorProcess As WqlEventQuery = New WqlEventQuery("__InstanceCreationEvent", New TimeSpan(0, 0, 0, 1), "TargetInstance isa ""Win32_Process""")
       proc_watcher = New ManagementEventWatcher(colMonitorProcess)
       AddHandler proc_watcher.EventArrived, AddressOf Process_started
   End Sub

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900