1 out of 3 rated this helpful - Rate this topic

EventSource Class

.NET Framework 4.5

Provides the ability to create events for event tracing for Windows (ETW).

System.Object
  System.Diagnostics.Tracing.EventSource

Namespace:  System.Diagnostics.Tracing
Assembly:  mscorlib (in mscorlib.dll)
type EventSource =  
    class 
        interface IDisposable 
    end

The EventSource type exposes the following members.

  NameDescription
Protected methodSupported in .NET for Windows Store appsEventSource()Creates a new instance of the EventSource class.
Protected methodSupported in .NET for Windows Store appsEventSource(Boolean)Creates a new instance of the EventSource class and specifies whether to throw an exception when an error occurs in the underlying Windows code.
Top
  NameDescription
Public propertyConstructionException [This topic is preliminary and is subject to change.]
Gets any exception that was thrown during the construction of the event source.
Public propertyStatic memberCurrentThreadActivityId [This topic is preliminary and is subject to change.]
Gets the activity ID of the current thread.
Public propertySupported in .NET for Windows Store appsGuidThe unique identifier for the event source.
Public propertySupported in .NET for Windows Store appsNameThe friendly name of the class that is derived from the event source.
Top
  NameDescription
Public methodSupported in .NET for Windows Store appsDispose()Releases all resources used by the current instance of the EventSource class.
Protected methodSupported in .NET for Windows Store appsDispose(Boolean)Releases the unmanaged resources used by the EventSource class and optionally releases the managed resources.
Public methodSupported in .NET for Windows Store appsEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported in .NET for Windows Store appsFinalizeAllows the EventSource object to attempt to free resources and perform other cleanup operations before the object is reclaimed by garbage collection. (Overrides Object.Finalize().)
Public methodStatic memberSupported in .NET for Windows Store appsGenerateManifestReturns a string of the XML manifest that is associated with the current event source.
Public methodStatic memberSupported in .NET for Windows Store appsGetGuidGets the unique identifier for this implementation of the event source.
Public methodSupported in .NET for Windows Store appsGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodStatic memberSupported in .NET for Windows Store appsGetNameGets the friendly name of the event source.
Public methodStatic memberSupported in .NET for Windows Store appsGetSourcesGets a snapshot of all the event sources for the application domain.
Public methodSupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported in .NET for Windows Store appsIsEnabled()Determines whether the current event source is enabled.
Public methodSupported in .NET for Windows Store appsIsEnabled(EventLevel, EventKeywords)Determines whether the current event source that has the specified level and keyword is enabled.
Protected methodSupported in .NET for Windows Store appsMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodSupported in .NET for Windows Store appsOnEventCommandCalled when the current event source is updated by the controller.
Public methodStatic memberSupported in .NET for Windows Store appsSendCommandSends a command to a specified event source.
Public methodStatic memberSetCurrentThreadActivityId(Guid) [This topic is preliminary and is subject to change.]
Sets the activity ID on the current thread.
Public methodStatic memberSetCurrentThreadActivityId(Guid, Guid) [This topic is preliminary and is subject to change.]
Sets the activity ID on the current thread, and returns the previous activity ID.
Public methodSupported in .NET for Windows Store appsToStringObtains a string representation of the current event source instance. (Overrides Object.ToString().)
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32)Writes an event by using the provided event identifier.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, Int32)Writes an event by using the provided event identifier and 32-bit integer argument.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, Int64)Writes an event by using the provided event identifier and 64-bit integer argument.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, Object[])Writes an event by using the provided event identifier and array of arguments.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, String)Writes an event by using the provided event identifier and string argument.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, Int32, Int32)Writes an event by using the provided event identifier and 32-bit integer arguments.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, Int64, Int64)Writes an event by using the provided event identifier and 64-bit arguments.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, String, Int32)Writes an event by using the provided event identifier and arguments.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, String, Int64)Writes an event by using the provided event identifier and arguments.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, String, String)Writes an event by using the provided event identifier and string arguments.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, Int32, Int32, Int32)Writes an event by using the provided event identifier and 32-bit integer arguments.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, Int64, Int64, Int64)Writes an event by using the provided event identifier and 64-bit arguments.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, String, Int32, Int32)Writes an event by using the provided event identifier and arguments.
Protected methodSupported in .NET for Windows Store appsWriteEvent(Int32, String, String, String)Writes an event by using the provided event identifier and string arguments.
Protected methodSupported in .NET for Windows Store appsWriteEventCoreCreates a new WriteEvent overload by using the provided event identifier and event data.
Protected methodWriteEventWithRelatedActivityId [This topic is preliminary and is subject to change.]
Writes an event that indicates that the current activity is related to another activity.
Protected methodWriteEventWithRelatedActivityIdCore [This topic is preliminary and is subject to change.]
Writes an event that indicates that the current activity is related to another activity.
Top

This class is intended to be inherited by a user class that provides specific events to be used for ETW. The EventSource.WriteEvent methods are called to log the events.

The basic functionality of EventSource is sufficient for most applications. If you want more control over the ETW manifest that is created, you can apply the EventAttribute attribute to the methods. For advanced event source applications, it is possible to intercept the commands being sent to the derived event source and change the filtering, or to cause actions (such as dumping a data structure) to be performed by the inheritor. An event source can be activated with Windows ETW controllers, such as the Logman tool, immediately. It is also possible to programmatically control and intercept the data dispatcher. The EventListener class provides additional functionality.

The following example shows a simple implementation of the EventSource class.

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

The following example shows a more complex implementation of the EventSource class.

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

.NET Framework

Supported in: 4.5

.NET for Windows Store apps

Supported in: Windows 8

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.
Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.