This documentation is archived and is not being maintained.

WqlEventQuery Constructor (String, TimeSpan, String)

Initializes a new instance of the WqlEventQuery class with the specified event class name, polling interval, and condition.

Namespace:  System.Management
Assembly:  System.Management (in System.Management.dll)

public WqlEventQuery(
	string eventClassName,
	TimeSpan withinInterval,
	string condition


Type: System.String
The name of the event class to query.
Type: System.TimeSpan
A TimeSpan value specifying the latency acceptable for receiving this event. This value is used in cases where there is no explicit event provider for the query requested and WMI is required to poll for the condition. This interval is the maximum amount of time that can pass before notification of an event must be delivered.
Type: System.String
The condition to apply to events of the specified class.

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

The following example creates the event query: "SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE TargetInstance ISA Win32_Service ", which sends notification of the creation of Win32_Service instances, with a 10-second polling interval.

using System;
using System.Management;

public class EventSample 
    public static void Main(string[] args) 
        // Requests notification of the creation
        // of Win32_Service instances with
        // a 10 second allowed latency.
        WqlEventQuery q = new WqlEventQuery("__InstanceCreationEvent", 
            new TimeSpan(0,0,10), 
            "TargetInstance isa 'Win32_Service'");


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.