Bewerken

Share via


EventSource.WriteEventWithRelatedActivityIdCore Method

Definition

Important

This API is not CLS-compliant.

Writes an event that indicates that the current activity is related to another activity.

protected:
 void WriteEventWithRelatedActivityIdCore(int eventId, Guid* relatedActivityId, int eventDataCount, System::Diagnostics::Tracing::EventSource::EventData* data);
protected:
 void WriteEventWithRelatedActivityIdCore(int eventId, Guid* childActivityID, int eventDataCount, System::Diagnostics::Tracing::EventSource::EventData* data);
[System.CLSCompliant(false)]
[System.Security.SecurityCritical]
protected void WriteEventWithRelatedActivityIdCore (int eventId, Guid* relatedActivityId, int eventDataCount, System.Diagnostics.Tracing.EventSource.EventData* data);
[System.CLSCompliant(false)]
protected void WriteEventWithRelatedActivityIdCore (int eventId, Guid* relatedActivityId, int eventDataCount, System.Diagnostics.Tracing.EventSource.EventData* data);
[System.CLSCompliant(false)]
[System.Security.SecurityCritical]
protected void WriteEventWithRelatedActivityIdCore (int eventId, Guid* childActivityID, int eventDataCount, System.Diagnostics.Tracing.EventSource.EventData* data);
[<System.CLSCompliant(false)>]
[<System.Security.SecurityCritical>]
member this.WriteEventWithRelatedActivityIdCore : int * nativeptr<Guid> * int * nativeptr<System.Diagnostics.Tracing.EventSource.EventData> -> unit
[<System.CLSCompliant(false)>]
member this.WriteEventWithRelatedActivityIdCore : int * nativeptr<Guid> * int * nativeptr<System.Diagnostics.Tracing.EventSource.EventData> -> unit

Parameters

eventId
Int32

An identifier that uniquely identifies this event within the EventSource.

relatedActivityIdchildActivityID
Guid*

A pointer to the GUID of the related activity ID.

eventDataCount
Int32

The number of items in the data field.

data
EventSource.EventData

A pointer to the first item in the event data field.

Attributes

Examples

The following C# code example shows how to define a method overload that calls WriteEventWithRelatedActivityIdCore.

[EventSource(Name = "Litware-ProductName-ComponentName")]
public sealed class LitwareComponentNameEventSource : EventSource
{
    [Event(1, Task = Tasks.Request, Opcode = EventOpcode.Send)]
    public void RequestStart(Guid relatedActivityId, int reqId, string url)
    {
        WriteEventWithRelatedActivityIdCore(1, relatedActivityId, reqId, url);
    }
}
<EventSource(Name:="Litware-ProductName-ComponentName")> _
Public NotInheritable Class LitwareComponentNameEventSource
    Inherits EventSource
    <[Event](1, Task:=Tasks.Request, Opcode:=EventOpcode.Send)> _
    Public Sub RequestStart(relatedActivityId As Guid, reqId As Integer, url As String)
        WriteEventWithRelatedActivityIdCore(1, relatedActivityId, reqId, url)
    End Sub

End Class
#region Keywords / Task / Opcodes
public static class Tasks
{
    public const EventTask Request = (EventTask)0x1;
}
#endregion
#Region "Keywords / Task / Opcodes"
    Public NotInheritable Class Tasks
        Private Sub New()
        End Sub
        Public Const Request As EventTask = DirectCast(&H1, EventTask)
    End Class
#End Region

Remarks

WriteEventWithRelatedActivityIdCore is similar to the WriteEventWithRelatedActivityId method but offers better performance, because it does not have to unbox the childActivityID and data arguments.

Your ETW event method calling this function must follow these guidelines:

  1. Specify the first parameter as a Guid named relatedActivityId.

  2. Specify either Send or Receive as the EventAttribute.Opcode property.

  3. Call WriteEventWithRelatedActivityIdCore passing in the event ID, followed by the related ID GUID, followed by all the parameters the event method is passed, in the same order.

This method uses the same rules as WriteEventCore for the args parameter. See WriteEventCore documentation for more details.

Applies to