EventWatcherOptions コンストラクタ ()とは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > EventWatcherOptions コンストラクタ ()の意味・解説 

EventWatcherOptions コンストラクタ ()

イベント ウォッチのための EventWatcherOptions クラス新しインスタンスを、既定値使用して初期化します。これは既定コンストラクタです。

名前空間: System.Management
アセンブリ: System.Management (system.management.dll 内)
構文構文

Dim instance As New EventWatcherOptions
public EventWatcherOptions ()
public:
EventWatcherOptions ()
public EventWatcherOptions ()
public function EventWatcherOptions ()
使用例使用例

イベント クラス__InstanceCreationEvent であるために、Win32_Processインスタンス作成されたときにクライアント通知受信するしくみを説明する例を次に示します詳細については、MSDN ライブラリ (http://msdn.microsoft.com/library/ja) で Windows Management Instrumentation に関するドキュメント参照してくださいクライアントは WaitForNextEvent メソッド呼び出してイベント同期的受信します。この例は、コード例実行中メモ帳などのプロセス開始することでテストできます

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 second of 
        ' a change in a service
        Dim query As String
        query = "SELECT * FROM" & _
            " __InstanceCreationEvent WITHIN 1 " &
 _
            "WHERE TargetInstance isa ""Win32_Process"""

        ' Event options
        Dim eventOptions As New
 EventWatcherOptions
        eventOptions.Timeout = System.TimeSpan.MaxValue

        ' Initialize an event watcher and subscribe to events 
        ' that match this query
        Dim watcher As New
 ManagementEventWatcher( _
            "root\CIMV2", query, eventOptions)

        ' 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 change in a service
        string query = "SELECT * FROM" +
            " __InstanceCreationEvent WITHIN 1 " + 
            "WHERE TargetInstance isa \"Win32_Process\"";

        // Event options
        EventWatcherOptions eventOptions = new
            EventWatcherOptions();
        eventOptions.Timeout = System.TimeSpan.MaxValue;

        // Initialize an event watcher and subscribe to events 
        // that match this query
        ManagementEventWatcher watcher =
            new ManagementEventWatcher("root\\CIMV2",
 query,
            eventOptions);
      
        // 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;
    }
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EventWatcherOptions クラス
EventWatcherOptions メンバ
System.Management 名前空間

EventWatcherOptions コンストラクタ (ManagementNamedValueCollection, TimeSpan, Int32)

指定した値を使用して、EventWatcherOptions クラス新しインスタンス初期化します。

名前空間: System.Management
アセンブリ: System.Management (system.management.dll 内)
構文構文

Public Sub New ( _
    context As ManagementNamedValueCollection, _
    timeout As TimeSpan, _
    blockSize As Integer _
)
Dim context As ManagementNamedValueCollection
Dim timeout As TimeSpan
Dim blockSize As Integer

Dim instance As New EventWatcherOptions(context,
 timeout, blockSize)
public EventWatcherOptions (
    ManagementNamedValueCollection context,
    TimeSpan timeout,
    int blockSize
)
public:
EventWatcherOptions (
    ManagementNamedValueCollection^ context, 
    TimeSpan timeout, 
    int blockSize
)
public EventWatcherOptions (
    ManagementNamedValueCollection context, 
    TimeSpan timeout, 
    int blockSize
)
public function EventWatcherOptions (
    context : ManagementNamedValueCollection, 
    timeout : TimeSpan, 
    blockSize : int
)

パラメータ

context

プロバイダ渡されるプロバイダ固有情報格納しているオプション コンテキスト オブジェクト

timeout

次のイベント待機するタイムアウト

blockSize

ブロック待機するイベント数。

使用例使用例

イベント クラス__InstanceCreationEvent であるために、Win32_Processインスタンス作成されたときにクライアント通知受信するしくみを説明する例を次に示します詳細については、MSDN ライブラリ (http://msdn.microsoft.com/library/ja) で Windows Management Instrumentation に関するドキュメント参照してくださいクライアントは WaitForNextEvent メソッド呼び出してイベント同期的受信します。この例は、コード例実行中メモ帳などのプロセス開始することでテストできます

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 second of 
        ' a change in a service
        Dim query As String
        query = "SELECT * FROM" & _
            " __InstanceCreationEvent WITHIN 1 " &
 _
            "WHERE TargetInstance isa ""Win32_Process"""

        ' Event options
        ' blockSize = 1 to receive one event
        Dim eventOptions As New
 EventWatcherOptions( _
            Nothing, System.TimeSpan.MaxValue, 1)

        ' Initialize an event watcher and subscribe to events 
        ' that match this query
        Dim watcher As New
 ManagementEventWatcher( _
            "root\CIMV2", query, eventOptions)

        ' 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 change in a service
        string query = "SELECT * FROM" +
            " __InstanceCreationEvent WITHIN 1 " + 
            "WHERE TargetInstance isa \"Win32_Process\"";

        // Event options
        // blockSize = 1 to receive one event
        EventWatcherOptions eventOptions = new
            EventWatcherOptions(null, System.TimeSpan.MaxValue
,
            1);

        // Initialize an event watcher and subscribe to events 
        // that match this query
        ManagementEventWatcher watcher =
            new ManagementEventWatcher("root\\CIMV2",
 query,
            eventOptions);
      
        // 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;
    }
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EventWatcherOptions クラス
EventWatcherOptions メンバ
System.Management 名前空間

EventWatcherOptions コンストラクタ


オーバーロードの一覧オーバーロードの一覧

名前 説明
EventWatcherOptions () イベント ウォッチのための EventWatcherOptions クラス新しインスタンスを、既定値使用して初期化します。これは既定コンストラクタです。
EventWatcherOptions (ManagementNamedValueCollection, TimeSpan, Int32) 指定した値を使用してEventWatcherOptions クラス新しインスタンス初期化します。
参照参照

関連項目

EventWatcherOptions クラス
EventWatcherOptions メンバ
System.Management 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「EventWatcherOptions コンストラクタ ()」の関連用語

EventWatcherOptions コンストラクタ ()のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



EventWatcherOptions コンストラクタ ()のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS