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*

相關活動識別碼之 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 方法,但提供較佳的效能,因為它不需要將 和 data 自變數取消收件childActivityID匣。

呼叫此函式的 ETW 事件方法必須遵循下列指導方針:

  1. 將第一個 Guid 參數指定為名為 relatedActivityId

  2. Send指定 或 Receive 做為 EventAttribute.Opcode 屬性。

  3. 呼叫 WriteEventWithRelatedActivityIdCore 傳入事件標識符,後面接著相關的標識符 GUID,後面接著傳遞事件方法的所有參數,順序相同。

這個方法會使用與 WriteEventCoreargs 參數相同的規則。 如需詳細資訊,請參閱 WriteEventCore 檔。

適用於