This documentation is archived and is not being maintained.

WqlEventQuery Constructor (String, TimeSpan)

Initializes a new instance of the WqlEventQuery class for the specified event class, with the specified latency time.

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

public WqlEventQuery(
	string eventClassName,
	TimeSpan withinInterval
)

Parameters

eventClassName
Type: System.String
The name of the event class to query.
withinInterval
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.

.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 initializes a WqlEventQuery by specifying an event and a time span value specifying the latency acceptable for receiving this event.


using System;
using System.Management;

public class EventSample 
{
    public static void Main(string[] args) 
    {
        // Requests all instance creation events,
        // with a specified latency of
        // 10 seconds. The query created
        // is "SELECT * FROM __InstanceCreationEvent WITHIN 10"
        WqlEventQuery q = new WqlEventQuery("__InstanceCreationEvent",
            new TimeSpan(0,0,10));


        Console.WriteLine(q.QueryString);
        return;
    }
}


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