EventSource.WriteEventWithRelatedActivityIdCore(Int32, Guid*, Int32, EventSource+EventData*) 方法

定义

重要

此 API 不符合 CLS。

写入一个指示当前活动与其他活动相关的事件。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

参数

eventId
Int32

EventSource 中唯一标识此事件的标识符。An identifier that uniquely identifies this event within the EventSource.

relatedActivityIdchildActivityID
Guid*

指向相关活动 ID 的 GUID 的指针。A pointer to the GUID of the related activity ID.

eventDataCount
Int32

data 字段中的项数。The number of items in the data field.

data
EventSource.EventData

指向事件数据字段中第一个项的指针。A pointer to the first item in the event data field.

属性

示例

下面的 c # 代码示例演示如何定义调用的方法重载 WriteEventWithRelatedActivityIdCoreThe 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

注解

WriteEventWithRelatedActivityIdCore 类似于 WriteEventWithRelatedActivityId 方法,但提供更好的性能,bevcause 它无需取消装箱 childActivityIDdata 参数。WriteEventWithRelatedActivityIdCore is similar to the WriteEventWithRelatedActivityId method but offers better performance, bevcause it does not have to unbox the childActivityID and data arguments.

调用此函数的 ETW 事件方法必须遵循以下准则:Your ETW event method calling this function must follow these guidelines:

  1. 将第一个参数指定为 Guid 名为的 relatedActivityIdSpecify the first parameter as a Guid named relatedActivityId.

  2. Send将或指定 ReceiveEventAttribute.Opcode 属性。Specify either Send or Receive as the EventAttribute.Opcode property.

  3. 调用 WriteEventWithRelatedActivityIdCore 传入事件 id,后跟相关 ID GUID,后跟以相同顺序传递的事件方法的所有参数。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.

适用于