EventSource.WriteEventWithRelatedActivityIdCore 方法

定义

重要

此 API 不符合 CLS。

写入一个指示当前活动与其他活动相关的事件。

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 中唯一标识此事件的标识符。

relatedActivityIdchildActivityID
Guid*

指向相关活动 ID 的 GUID 的指针。

eventDataCount
Int32

data 字段中的项数。

data
EventSource.EventData

指向事件数据字段中第一个项的指针。

属性

示例

以下 C# 代码示例演示如何定义调用 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 但性能更好,因为它不必取消装箱 childActivityIDdata 参数。

调用此函数的 ETW 事件方法必须遵循以下准则:

  1. 将第一个 Guid 参数指定为名为 relatedActivityId的 。

  2. Send将 或 Receive 指定为 EventAttribute.Opcode 属性。

  3. 调用 WriteEventWithRelatedActivityIdCore 传入事件 ID,后跟相关 ID GUID,后跟传递事件方法的所有参数,顺序相同。

此方法使用与 参数args相同的规则WriteEventCore。 有关更多详细信息,请参阅 WriteEventCore 文档。

适用于