DragosI
October 1st, 2004, 05:23 PM
Hi,
I am trying to use the WMI event notification. The following lines of code work fine:
string eventquery = "SELECT * FROM __InstanceModificationEvent WITHIN 3 WHERE TargetInstance ISA \"Win32_PerfFormattedData_PerfOS_System\" AND TargetInstance.Processes > 35";
m_handler = new MyEventAsyncHandler();
m_watcher = new ManagementEventWatcher(eventquery);
m_watcher.EventArrived += new EventArrivedEventHandler m_handler.EventArrived);
m_watcher.Stopped += new StoppedEventHandler(m_handler.StoppedEvent);
m_watcher.Start();
With this code I am being notified whenever the number of processes goes over 35. However, I am trying to find a way to combine two queries in a single one, if possible. I would like to receive a SINGLE notification when both conditions are satisfied. This would be easy if my second condition was part of the same class (Win32_PerfFormattedData_PerfOS_System in this case) but if I have different classes, I can't find a way to combine 2 queries/events in a single one.
An example of a second query would be:
string eventquery = "SELECT * FROM __InstanceModificationEvent WITHIN 3 WHERE TargetInstance ISA \"Win32_PerfFormattedData_PerfOS_PagingFile\" AND TargetInstance.PercentUsage> 50";
m_handler = new MyEventAsyncHandler();
m_watcher = new ManagementEventWatcher(eventquery);
m_watcher.EventArrived += new EventArrivedEventHandler m_handler.EventArrived);
m_watcher.Stopped += new StoppedEventHandler(m_handler.StoppedEvent);
m_watcher.Start();
Is there a way to combine the 2 events in a single one? If not, are there any workarounds?
Thank you.
I am trying to use the WMI event notification. The following lines of code work fine:
string eventquery = "SELECT * FROM __InstanceModificationEvent WITHIN 3 WHERE TargetInstance ISA \"Win32_PerfFormattedData_PerfOS_System\" AND TargetInstance.Processes > 35";
m_handler = new MyEventAsyncHandler();
m_watcher = new ManagementEventWatcher(eventquery);
m_watcher.EventArrived += new EventArrivedEventHandler m_handler.EventArrived);
m_watcher.Stopped += new StoppedEventHandler(m_handler.StoppedEvent);
m_watcher.Start();
With this code I am being notified whenever the number of processes goes over 35. However, I am trying to find a way to combine two queries in a single one, if possible. I would like to receive a SINGLE notification when both conditions are satisfied. This would be easy if my second condition was part of the same class (Win32_PerfFormattedData_PerfOS_System in this case) but if I have different classes, I can't find a way to combine 2 queries/events in a single one.
An example of a second query would be:
string eventquery = "SELECT * FROM __InstanceModificationEvent WITHIN 3 WHERE TargetInstance ISA \"Win32_PerfFormattedData_PerfOS_PagingFile\" AND TargetInstance.PercentUsage> 50";
m_handler = new MyEventAsyncHandler();
m_watcher = new ManagementEventWatcher(eventquery);
m_watcher.EventArrived += new EventArrivedEventHandler m_handler.EventArrived);
m_watcher.Stopped += new StoppedEventHandler(m_handler.StoppedEvent);
m_watcher.Start();
Is there a way to combine the 2 events in a single one? If not, are there any workarounds?
Thank you.