WMI and Quota violation exception

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dilip

    WMI and Quota violation exception

    Hi

    I am using the following WMI code to watch for the termination of a
    particular process. This code is running under Windows Vista.

    public void WaitForDeath()
    {
    using (AutoResetEvent thisEvent = WatchForProcess Death())
    {
    WaitHandle.Wait One(thisEvent);
    }
    }

    private AutoResetEvent WatchForProcess Death()
    {
    AutoResetEvent evt = new AutoResetEvent( false);
    string newQry =
    "select * from __InstanceDelet ionEvent within 2 where
    TargetInstance ISA 'Win32_Process' and " +
    "TargetInstance .Name = 'MyProcess.exe' ";
    ManagementEvent Watcher mew = new ManagementEvent Watcher(@"\\.\r oot
    \CIMV2", newQry);
    mew.EventArrive d += delegate { evt.Set(); };
    mew.Start();
    return evt;
    }

    Our QA folks tested this functionality by calling WaitForDeath()
    repeatedly in a tight loop. at some point, say after 3 hours or so,
    we started getting a "Quota violation" exception of type
    System.Manageme ntException on the Start() method of
    ManagementEvent Watcher.

    I happened upon some posts related to this on the WMI newsgroup but I
    am not clear how to solve this in my case.

    1) Is this happening because of the query itself? If so, why does it
    happen only after 3 hours and not right away?
    2) Is this happening because I am not properly disposing of the
    ManagementEvent Watcher objects? In the EventArrived event I could
    add:

    mew.Stop();
    mew.Dispose();

    in addition to setting the autoreset event. I just don't know enough
    about WMI to decide if it would help.

    Can anyone help? (From past experience I really hope Mr. Willy
    Denoyette sees this!)

Working...