WqlEventQuery.WithinInterval プロパティ
アセンブリ: System.Management (system.management.dll 内)

Dim instance As WqlEventQuery Dim value As TimeSpan value = instance.WithinInterval instance.WithinInterval = value
/** @property */ public TimeSpan get_WithinInterval () /** @property */ public void set_WithinInterval (TimeSpan value)
public function get WithinInterval () : TimeSpan public function set WithinInterval (value : TimeSpan)
イベント クエリで使用するポーリング間隔を格納している TimeSpan 値を返します。

このプロパティは、要求するイベントに対してイベント プロバイダがないクラスだけで設定します。WMI は、要求された条件をポーリングする必要があります。
このプロパティ値を設定すると、それまでにオブジェクトに格納された値をすべてオーバーライドします。クエリ文字列は新しい間隔を反映するようにリビルドされます。
プロパティ値.NET Framework のセキュリティ

クエリ "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process'" を表す新しい WqlEventQuery を初期化する例を次に示します。
Imports System 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 'EventWatcherPolling
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; } }


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からWqlEventQuery.WithinInterval プロパティを検索する場合は、下記のリンクをクリックしてください。

- WqlEventQuery.WithinInterval プロパティのページへのリンク