Export (0) Print
Expand All

BaseEvent Class

Represents classes derived from BaseEvent that are known to be management event classes. These derived classes inherit an implementation of IEvent that allows events to be fired through the Fire method.

For a list of all members of this type, see BaseEvent Members.

System.Object
   System.Management.Instrumentation.BaseEvent

[Visual Basic]
MustInherit Public Class BaseEvent
   Implements IEvent
[C#]
public abstract class BaseEvent : IEvent
[C++]
public __gc __abstract class BaseEvent : public IEvent
[JScript]
public abstract class BaseEvent implements IEvent

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Example

[C#] 
using System;
using System.Management;
using System.Configuration.Install;
using System.Management.Instrumentation;

// This example demonstrates how to create a Management Event class by deriving
// from BaseEvent class and to fire a Management Event from managed code.

// Specify which namespace the Manaegment Event class is created in
[assembly:Instrumented("Root/Default")]

// Let the system know you will run InstallUtil.exe utility against
// this assembly
[System.ComponentModel.RunInstaller(true)]
public class MyInstaller : DefaultManagementProjectInstaller {}

// Create a Management Instrumentation Event class
public class MyEvent : BaseEvent
{
    public string EventName;
}

public class Sample_EventProvider
{
    public static int Main(string[] args) {
       MyEvent e = new MyEvent();
       e.EventName = "Hello";
       
       // Fire the Management Event
       e.Fire();
       
       return 0;
    }
}
   
[Visual Basic] 
Imports System
Imports System.Management
Imports System.Configuration.Install
Imports System.Management.Instrumentation

' This sample demonstrates how to create a Management Event class by deriving
' from BaseEvent class and to fire a Management Event from managed code.

' Specify which namespace the Manaegment Event class is created in
<assembly: Instrumented("Root/Default")>

' Let the system know InstallUtil.exe utility will be run against
' this assembly
<System.ComponentModel.RunInstaller(True)> _
Public Class MyInstaller
    Inherits DefaultManagementProjectInstaller
End Class

' Create a Management Instrumentation Event class
<InstrumentationClass(InstrumentationType.Event)> _ 
Public Class MyEvent
    Inherits BaseEvent
    Public EventName As String
End Class

Public Class Sample_EventProvider
    Public Shared Function Main(args() As String) As Integer
        Dim e As New MyEvent()
        e.EventName = "Hello"

        ' Fire the Management Event
        e.Fire()

        Return 0
    End Function
End Class
   

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Management.Instrumentation

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

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

See Also

BaseEvent Members | System.Management.Instrumentation Namespace

Show:
© 2014 Microsoft