EventWrittenEventArgs Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides data for the OnEventWritten(EventWrittenEventArgs) callback.
public ref class EventWrittenEventArgs : EventArgs
public class EventWrittenEventArgs : EventArgs
type EventWrittenEventArgs = class
inherit EventArgs
Public Class EventWrittenEventArgs
Inherits EventArgs
- Inheritance
Remarks
The EventWrittenEventArgs class provides data for the OnEventWritten callback.
Whenever an event is dispatched to an EventListener, the EventListener.OnEventWritten callback method is invoked. It is passed an EventWrittenEventArgs instance that contains information associated with the event. All property values of the EventWrittenEventArgs class are valid only during the callback.
The following sections contain additional information about individual EventWrittenEventArgs properties.
ActivityId property
When using System.Activities.Activity and its derived classes, threads can be marked as having an activity associated with them. The ActivityId property returns the activity ID of the thread that logged the event. Note that threads do not have to have an activity, in which case this property returns Guid.Empty.
OSThreadId and TimeStamp properties
Starting with .NET Core 2.2, EventListener objects can subscribe to native runtime events (such as GC, JIT, and threadpool events) in addition to events emitted by EventSource objects. In previous versions of .NET Core and all versions of .NET Framework, the thread ID and timestamp can be gathered from the environment, because they are dispatched synchronously on the same thread that emitted them. Not all native runtime events can be dispatched synchronously, however. Some events, such as GC events, are emitted when managed thread execution is suspended. These events are buffered in native code and are dispatched by a dispatcher thread once managed code can execute again. Because these events are buffered, the environment cannot be used to reliably retrieve the thread ID and timestamp. Because of this, starting with .NET Core 2.2, thread ID and timestamp information are available as members of the EventWrittenEventArgs class.
RelatedActivityId property
A related activity is an activity that is strongly related to the current one. Typically, it is either the activity that caused the current activity (events with the Start opcode typically do this) or an activity that was created by the current one (events with the Send opcode typically do this). When it is used, the RelatedActivityID is explicitly passed by the method doing the logging. Many events don't pass a RelatedActivityId, in which case this property returns Guid.Empty.
Properties
| Name | Description |
|---|---|
| ActivityId |
Gets the activity ID on the thread that the event was written to. |
| Channel |
Gets the channel for the event. |
| EventId |
Gets the event identifier. |
| EventName |
Gets the name of the event. |
| EventSource |
Gets the event source object. |
| Keywords |
Gets the keywords for the event. |
| Level |
Gets the level of the event. |
| Message |
Gets the message for the event. |
| Opcode |
Gets the operation code for the event. |
| OSThreadId |
Gets the thread identifier for the OS thread that wrote the event. (.NET Core 2.2 and later only.) |
| Payload |
Gets the payload for the event. |
| PayloadNames |
Returns a list of strings that represent the property names of the event. |
| RelatedActivityId |
Gets the identifier of an activity that is related to the activity represented by the current instance. |
| Tags |
Returns the tags specified in the call to the Write(String, EventSourceOptions) method. |
| Task |
Gets the task for the event. |
| TimeStamp |
Gets the time that the event was originally generated as a DateTime timestamp. (.NET Core 2.2 and later only.) |
| Version |
Gets the version of the event. |
Methods
| Name | Description |
|---|---|
| Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
| GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
| GetType() |
Gets the Type of the current instance. (Inherited from Object) |
| MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
| ToString() |
Returns a string that represents the current object. (Inherited from Object) |