Export (0) Print
Expand All

ManagementEventWatcher Class

Subscribes to temporary event notifications based on a specified event query.

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Management.ManagementEventWatcher

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

type ManagementEventWatcher =  
    class 
        inherit Component 
    end

The ManagementEventWatcher type exposes the following members.

  NameDescription
Public methodManagementEventWatcher()Initializes a new instance of the ManagementEventWatcher class. For further initialization, set the properties on the object. This is the default constructor.
Public methodManagementEventWatcher(EventQuery)Initializes a new instance of the ManagementEventWatcher class when given a WMI event query.
Public methodManagementEventWatcher(String)Initializes a new instance of the ManagementEventWatcher class when given a WMI event query in the form of a string.
Public methodManagementEventWatcher(ManagementScope, EventQuery)Initializes a new instance of the ManagementEventWatcher class that listens for events conforming to the given WMI event query.
Public methodManagementEventWatcher(String, String)Initializes a new instance of the ManagementEventWatcher class that listens for events conforming to the given WMI event query. For this variant, the query and the scope are specified as strings.
Public methodManagementEventWatcher(ManagementScope, EventQuery, EventWatcherOptions)Initializes a new instance of the ManagementEventWatcher class that listens for events conforming to the given WMI event query, according to the specified options. For this variant, the query and the scope are specified objects. The options object can specify options such as time-out and context information.
Public methodManagementEventWatcher(String, String, EventWatcherOptions)Initializes a new instance of the ManagementEventWatcher class that listens for events conforming to the given WMI event query, according to the specified options. For this variant, the query and the scope are specified as strings. The options object can specify options such as a time-out and context information.
Top

  NameDescription
Protected propertyCanRaiseEventsGets a value indicating whether the component can raise an event. (Inherited from Component.)
Public propertyContainerGets the IContainer that contains the Component. (Inherited from Component.)
Protected propertyDesignModeGets a value that indicates whether the Component is currently in design mode. (Inherited from Component.)
Protected propertyEventsGets the list of event handlers that are attached to this Component. (Inherited from Component.)
Public propertyOptionsGets or sets the options used to watch for events.
Public propertyQueryGets or sets the criteria to apply to events.
Public propertyScopeGets or sets the scope in which to watch for events (namespace or scope).
Public propertySiteGets or sets the ISite of the Component. (Inherited from Component.)
Top

  NameDescription
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDispose()Releases all resources used by the Component. (Inherited from Component.)
Protected methodDispose(Boolean)Releases the unmanaged resources used by the Component and optionally releases the managed resources. (Inherited from Component.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeEnsures that outstanding calls are cleared. This is the destructor for the object. In C#, finalizers are expressed using destructor syntax. (Overrides Component.Finalize().)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodGetServiceReturns an object that represents a service provided by the Component or by its Container. (Inherited from Component.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodMemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public methodStartSubscribes to events with the given query and delivers them, asynchronously, through the EventArrived event.
Public methodStopCancels the subscription whether it is synchronous or asynchronous.
Public methodToStringReturns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.)
Public methodWaitForNextEventWaits for the next event that matches the specified query to arrive, and then returns it.
Top

  NameDescription
Public eventDisposedOccurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)
Public eventEventArrivedOccurs when a new event arrives.
Public eventStoppedOccurs when a subscription is canceled.
Top

The following example shows how the client receives notification when an instance of Win32_Process is created because the event class is __InstanceCreationEvent. For more information, see the Windows Management Instrumentation documentation in the MSDN Library at http://msdn.microsoft.com/library. The client receives events synchronously by calling the WaitForNextEvent method. This example can be tested by starting a process, such as Notepad, while the example code is running.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft