WqlEventQuery.WithinInterval 속성

정의

이 쿼리에 사용할 폴링 간격을 가져오거나 설정합니다.

public:
 property TimeSpan WithinInterval { TimeSpan get(); void set(TimeSpan value); };
public TimeSpan WithinInterval { get; set; }
member this.WithinInterval : TimeSpan with get, set
Public Property WithinInterval As TimeSpan

속성 값

TimeSpan

이벤트 쿼리에 사용할 폴링 간격이 들어 있는 TimeSpan 값을 반환합니다.

예제

다음 예제에서는 새 WqlEventQuery 쿼리를 나타내는: "선택 *에서 __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process'"입니다.

using System;
using System.Management;

// This example shows synchronous consumption of events.
// The client is blocked while waiting for events.

public class EventWatcherPolling
{
    public static int Main(string[] args)
    {
        // Create event query to be notified within 1 second of
        // a new process being created
        WqlEventQuery query =
            new WqlEventQuery("__InstanceCreationEvent",
            new TimeSpan(0,0,1),
            "TargetInstance isa \"Win32_Process\"");

        // Initialize an event watcher and subscribe to events
        // that match this query
        ManagementEventWatcher watcher =
            new ManagementEventWatcher(query);
        // times out watcher.WaitForNextEvent in 5 seconds
        watcher.Options.Timeout = new TimeSpan(0,0,5);

        // Block until the next event occurs
        // Note: this can be done in a loop if waiting for
        //        more than one occurrence
        Console.WriteLine(
            "Open an application (notepad.exe) to trigger an event.");
        ManagementBaseObject e = watcher.WaitForNextEvent();

        //Display information from the event
        Console.WriteLine(
            "Process {0} has been created, path is: {1}",
            ((ManagementBaseObject)e
            ["TargetInstance"])["Name"],
            ((ManagementBaseObject)e
            ["TargetInstance"])["ExecutablePath"]);

        //Cancel the subscription
        watcher.Stop();
        return 0;
    }
}
Imports System.Management

' This example shows synchronous consumption of events. 
' The client is blocked while waiting for events. 

Public Class EventWatcherPolling
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Create event query to be notified within 1 seconds of 
        ' a process being created
        Dim query As New WqlEventQuery( _
            "__InstanceCreationEvent", _
            New TimeSpan(0, 0, 1), _
            "TargetInstance isa ""Win32_Process""")

        ' Initialize an event watcher and subscribe to events 
        ' that match this query
        Dim watcher As New ManagementEventWatcher(query)
        ' times watcher.WaitForNextEvent in 5 seconds
        watcher.Options.Timeout = New TimeSpan(0, 0, 5)

        ' Block until the next event occurs 
        ' Note: this can be done in a loop
        ' if waiting for more than one occurrence
        Console.WriteLine( _
          "Open an application (notepad.exe) to trigger an event.")
        Dim e As ManagementBaseObject = _
            watcher.WaitForNextEvent()

        'Display information from the event
        Console.WriteLine( _
            "Process {0} has created, path is: {1}", _
            CType(e("TargetInstance"), _
                ManagementBaseObject)("Name"), _
            CType(e("TargetInstance"), _
                ManagementBaseObject)("ExecutablePath"))

        'Cancel the subscription
        watcher.Stop()
        Return 0

    End Function 'Main
End Class

설명

이 속성의 경우에서에 설정 해야가 없는 이벤트 공급자 이벤트 요청 및 요청 된 조건에 대해 폴링할 WMI가 있어야 합니다.

속성 값이 설정 개체에 저장 된 이전 값을 재정의 합니다. 쿼리 문자열 새 간격을 반영 하도록 빌드됩니다.

속성 값

Null이 있으면 없습니다 폴링 관련; 그렇지 않은 경우 유효한 TimeSpan 폴링 필요한 경우 값입니다.

.NET Framework 보안

직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분적으로 신뢰할 수 있는 코드에서 라이브러리를 사용 하 여입니다.

적용 대상