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);
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* 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);
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
[<System.CLSCompliant(false)>]
[<System.Security.SecurityCritical>]
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*

相關活動識別碼之 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. 請指定 SendReceive 做為 EventAttribute.Opcode 屬性。Specify either Send or Receive as the EventAttribute.Opcode property.

  3. 呼叫 WriteEventWithRelatedActivityIdCore 傳入事件識別碼,後面接著相關的識別碼 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.

適用於