This documentation is archived and is not being maintained.

WqlEventQuery Constructor (String, TimeSpan, String, TimeSpan, String[], String)

Initializes a new instance of the WqlEventQuery class with the specified event class name, condition, grouping interval, grouping properties, and specified number of events.

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

public WqlEventQuery(
	string eventClassName,
	TimeSpan withinInterval,
	string condition,
	TimeSpan groupWithinInterval,
	string[] groupByPropertyList,
	string havingCondition


Type: System.String
The name of the event class on which to be queried.
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.
Type: System.TimeSpan
The specified interval at which WMI sends one aggregate event, rather than many events.
Type: System.String[]
The properties in the event class by which the events should be grouped.
Type: System.String
The condition to apply to the number of events.

.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 WHERE TargetInstance ISA Win32_NTLogEvent GROUP WITHIN 600 BY TargetInstance.SourceName HAVING NumberOfEvents > 15" which delivers aggregate events only if the number of Win32_NTLogEvent events received from the same source exceeds 15.

using System;
using System.Management;

public class EventSample 
    public static void Main(string[] args) 
        // Requests sending aggregated events
        // if the number of events exceeds 15.
        String[] props = {"TargetInstance.SourceName"};
        WqlEventQuery q = 
            new WqlEventQuery(
            "TargetInstance isa 'Win32_NTLogEvent'", 
            new TimeSpan(0,10,0), 
            "NumberOfEvents >15");


.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.