Export (0) Print
Expand All

InstrumentationManager Class

Provides methods that manage the lifetime and the model used for decoupled providers.

System::Object
  System.Management.Instrumentation::InstrumentationManager

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

public ref class InstrumentationManager abstract sealed

The InstrumentationManager type exposes the following members.

  NameDescription
Public methodStatic memberPublishMakes an instance of a provider available within the WMI infrastructure.
Public methodStatic memberRegisterAssemblyRegisters an assembly with the WMI infrastructure.
Public methodStatic memberRegisterTypeRegisters a class with the WMI infrastructure.
Public methodStatic memberRevokeTakes an instance of a currently available provider and makes it unavailable within the WMI infrastructure.
Public methodStatic memberUnregisterAssemblyUnregisters an assembly currently registered with the WMI infrastructure.
Public methodStatic memberUnregisterTypeUnregisters a class registered with the WMI infrastructure.
Top

Decoupled providers are hosted by an application. Two methods can be used by the application to make instances of WMI classes available: publish/revoke or the callback method. The callback method uses the RegisterType and UnregisterType methods.

In the publish/revoke model, the WMI infrastructure provides default behavior for many of the methods you have to write yourself in the callback method. These include the enumeration and bind methods. In this model, the application creates instances and publishes them. The application is responsible for ensuring that the key properties of the classes are respected. The application is also responsible for deleting instances.

In the callback model, the WMI infrastructure expects the application to have methods that handle enumeration, binding and any other methods required to implement the functionality of the provider. It calls into the application for this functionality and fails if it does not exist or is not implemented properly. The application registers the type of its WMI classes with the infrastructure by calling RegisterType and indicates that it no longer wants the WMI classes exposed by calling UnregisterType.

The following example demonstrates how to use the publish/revoke model. Two instances of the router class are created and published. They are later revoked.

public class Sample_InstanceProvider
{
public int Main (string[] args) 
{
Router r_one = new Router ();
r_one.Name = "one";
InstrumentationManager.Publish(r_one);
Router r_two = new Router ();
r_two.Name = "two";
InstrumentationManager.Publish(r_two);
// ....
InstrumentationManager.Revoke(r_one);
InstrumentationManager.Revoke(r_two);
return 0;
}
}

In the next example, the callback method of registration is used to expose the RouterNew class.

public int MainNew(string[] args) 
{
    InstrumentationManager.RegisterType(typeof(RouterNew));
    // ....
    InstrumentationManager.UnRegisterType(typeof(RouterNew));
    return 0;
}

.NET Framework

Supported in: 4, 3.5

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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.

Community Additions

ADD
Show:
© 2014 Microsoft