EventSource.WriteEventCore Method
Creates a new WriteEvent overload by using the provided event identifier and event data.
This API is not CLS-compliant. Namespace: System.Diagnostics.Tracing
Assembly: mscorlib (in mscorlib.dll)
[CLSCompliantAttribute(false)] protected void WriteEventCore( int eventId, int eventDataCount, EventSource.EventData* data )
Parameters
- eventId
- Type: System.Int32
The event identifier.
- eventDataCount
- Type: System.Int32
The number of event data items.
- data
- Type: System.Diagnostics.Tracing.EventSource.EventData*
The structure that contains the event data.
This protected method enables users to define new WriteEvent overloads that are faster than the provided overloads. Creating a new overload involves unsafe code. The basic procedure is to stack-allocate an array of event data descriptors that matches the number of payload items. For each payload item, set the correct size and value in the event data array.Call WriteEventCore with the initialized array.
The following example shows how to add a WriteEvent overload that accepts four integer arguments.
[NonEvent]
public unsafe void WriteEvent(int eventId, int arg1, int arg2, int arg3, int arg4) {
EventData* dataDesc = stackalloc EventProvider.EventData[4];
dataDesc[0].DataPointer = (IntPtr)(&arg1);
dataDesc[0].Size = 4;
dataDesc[1].DataPointer = (IntPtr)(&arg2);
dataDesc[1].Size = 4;
dataDesc[2].DataPointer = (IntPtr)(&arg3);
dataDesc[2].Size = 4;
dataDesc[3].DataPointer = (IntPtr)(&arg4);
dataDesc[3].Size = 4;
WriteEventCore(eventId, 4, (IntPtr)dataDesc);
}
- SecurityCriticalAttribute
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
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.