EventSource.WriteEventWithRelatedActivityId(Int32, Guid, Object[]) 메서드

정의

현재 작업이 다른 작업과 연관되어 있음을 나타내는 이벤트를 기록합니다.

protected:
 void WriteEventWithRelatedActivityId(int eventId, Guid relatedActivityId, ... cli::array <System::Object ^> ^ args);
protected:
 void WriteEventWithRelatedActivityId(int eventId, Guid childActivityID, ... cli::array <System::Object ^> ^ args);
protected void WriteEventWithRelatedActivityId (int eventId, Guid relatedActivityId, params object[] args);
protected void WriteEventWithRelatedActivityId (int eventId, Guid relatedActivityId, params object?[] args);
protected void WriteEventWithRelatedActivityId (int eventId, Guid childActivityID, params object[] args);
member this.WriteEventWithRelatedActivityId : int * Guid * obj[] -> unit
member this.WriteEventWithRelatedActivityId : int * Guid * obj[] -> unit
Protected Sub WriteEventWithRelatedActivityId (eventId As Integer, relatedActivityId As Guid, ParamArray args As Object())
Protected Sub WriteEventWithRelatedActivityId (eventId As Integer, childActivityID As Guid, ParamArray args As Object())

매개 변수

eventId
Int32

EventSource 내에서 이 이벤트를 고유하게 식별하는 식별자입니다.

relatedActivityIdchildActivityID
Guid

관련 작업 식별자입니다.

args
Object[]

이벤트에 대한 데이터가 포함된 개체 배열입니다.

예제

다음 코드 예제에서는 를 호출 WriteEventWithRelatedActivityId하는 이벤트 원본을 지정할 수 있는 방법을 보여줍니다.

[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)
    {
        WriteEventWithRelatedActivityId(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)
        WriteEventWithRelatedActivityId(1, relatedActivityId, reqId, url)
    End Sub

End Class
[EventSource(Name = "Contoso-ProductName-ComponentName")]
public sealed class CustomizedForPerfEventSource : EventSource
{
    [Event(1, Task = Tasks.Request, Opcode = EventOpcode.Send)]
    public void RequestStart(Guid relatedActivityId, int reqId, string url)
    {
        if (IsEnabled())
            WriteEventWithRelatedActivityId(1, relatedActivityId, reqId, url);
    }

    [NonEvent]
    unsafe protected void WriteEventWithRelatedActivityId(int eventId, Guid relatedActivityId,
                    int arg1, string arg2)
    {
        if (IsEnabled())
        {
            if (arg2 == null) arg2 = string.Empty;
            fixed (char* stringBytes = arg2)
            {
                EventData* descrs = stackalloc EventData[2];
                descrs[0].DataPointer = (IntPtr)(&arg1);
                descrs[0].Size = 4;
                descrs[1].DataPointer = (IntPtr)stringBytes;
                descrs[1].Size = ((arg2.Length + 1) * 2);
                WriteEventWithRelatedActivityIdCore(eventId,
                &relatedActivityId, 2, descrs);
            }
        }
    }

설명

메서드는 WriteEventWithRelatedActivityId 전송 이벤트를 기록합니다. 현재 스레드의 활동은 이벤트와 함께 기록되며, 이를 통해 이벤트 소비자가 두 활동을 관련할 수 있습니다.

이 함수를 호출하는 ETW 이벤트 메서드는 다음 지침을 따라야 합니다.

  1. 첫 번째 매개 변수를 라는 relatedActivityId으로 Guid 지정합니다.

  2. 또는 SendReceive 을 속성으로 지정합니다 EventAttribute.Opcode .

  3. 이벤트 ID를 전달한 다음 관련 ID GUID를 전달한 다음 이벤트 메서드가 전달되는 모든 매개 변수를 동일한 순서로 호출 WriteEventWithRelatedActivityId 합니다.

가 사용되지 않으면 args ETW에 대한 결과 호출에 대해 빈 배열로 변환됩니다.

적용 대상