EventWatcherOptions 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
관리 이벤트 감시에 대한 옵션을 지정합니다.
public ref class EventWatcherOptions : System::Management::ManagementOptions
public class EventWatcherOptions : System.Management.ManagementOptions
type EventWatcherOptions = class
inherit ManagementOptions
Public Class EventWatcherOptions
Inherits ManagementOptions
- 상속
예제
다음 예제에서는 이벤트 클래스가 __InstanceCreationEvent 때문에 Win32_Process 인스턴스를 만들 때 클라이언트가 알림을 받는 방법을 보여 줍니다. 자세한 내용은 Windows Management Instrumentation 설명서를 참조하세요. 클라이언트는 메서드를 호출하여 이벤트를 동기적으로 수신합니다 WaitForNextEvent . 이 예제는 예제 코드가 실행되는 동안 메모장과 같은 프로세스를 시작하여 테스트할 수 있습니다.
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;
}
}
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
생성자
| Name | Description |
|---|---|
| EventWatcherOptions() |
기본값을 사용하여 이벤트 감시에 EventWatcherOptions 대한 클래스의 새 인스턴스를 초기화합니다. 매개 변수가 없는 생성자입니다. |
| EventWatcherOptions(ManagementNamedValueCollection, TimeSpan, Int32) |
지정된 값을 사용하여 클래스의 EventWatcherOptions 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| BlockSize |
블록 작업의 블록 크기를 가져오거나 설정합니다. 이벤트를 기다리는 경우 이 값은 반환하기 전에 대기할 이벤트 수를 지정합니다. |
| Context |
WMI 컨텍스트 개체를 가져오거나 설정합니다. 사용자 지정된 작업에 대한 컨텍스트 정보를 지원하는 WMI 공급자에게 전달될 이름-값 쌍 목록입니다. (다음에서 상속됨 ManagementOptions) |
| Timeout |
작업에 적용할 제한 시간을 가져오거나 설정합니다. 컬렉션을 반환하는 작업의 경우 이 제한 시간은 작업 자체가 아니라 결과 컬렉션을 통한 열거형에 적용됩니다( ReturnImmediately 속성은 후자에 사용됨). 이 속성은 작업이 반 동기적으로 수행되어야 함을 나타내는 데 사용됩니다. (다음에서 상속됨 ManagementOptions) |
메서드
| Name | Description |
|---|---|
| Clone() |
개체의 복사본을 반환합니다. |
| Equals(Object) |
지정된 개체가 현재 개체와 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetHashCode() |
기본 해시 함수로 사용됩니다. (다음에서 상속됨 Object) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |