EventSource.WriteEvent 方法

定義

使用所提供的事件識別元和選擇性引數,寫入事件。

多載

WriteEvent(Int32, String, String, String)

使用所提供的事件識別元和字串引數,寫入事件。

WriteEvent(Int32, String, Int32, Int32)

使用所提供的事件識別元和引數,寫入事件。

WriteEvent(Int32, Int64, Int64, Int64)

使用所提供的事件識別元和 64 位元整數引數,寫入事件。

WriteEvent(Int32, Int32, Int32, Int32)

使用所提供的事件識別元和 32 位元整數引數,寫入事件。

WriteEvent(Int32, String, String)

使用所提供的事件識別元和字串引數,寫入事件。

WriteEvent(Int32, String, Int64)

使用所提供的事件識別元和引數,寫入事件。

WriteEvent(Int32, String, Int32)

使用所提供的事件識別元和引數,寫入事件。

WriteEvent(Int32, Int64, String)

使用所提供的事件識別項、64 位元整數和字串引數,寫入事件。

WriteEvent(Int32, Int64, Int64)

使用所提供的事件識別元和 64 位元整數引數,寫入事件。

WriteEvent(Int32, Int32, Int32)

使用所提供的事件識別元和 32 位元整數引數,寫入事件。

WriteEvent(Int32, Int32, String)

使用所提供的事件識別項、32 位元整數和字串引數,寫入事件。

WriteEvent(Int32, String)

使用所提供的事件識別元和字串引數,寫入事件。

WriteEvent(Int32, Object[])

使用所提供的事件識別元和引數陣列,寫入事件。

WriteEvent(Int32, Int64)

使用所提供的事件識別元和 64 位元整數引數,寫入事件。

WriteEvent(Int32, Int32)

使用所提供的事件識別元和 32 位元整數引數,寫入事件。

WriteEvent(Int32, EventSource+EventSourcePrimitive[])

使用提供的事件識別碼和事件來源基本類型的變數數目來寫入事件。

WriteEvent(Int32, Byte[])

使用所提供的事件識別項和位元組陣列引數,寫入事件。

WriteEvent(Int32)

使用所提供的事件識別元,寫入事件。

WriteEvent(Int32, Int64, Byte[])

使用指定的識別項、64 位元整數和位元組陣列引數,寫入事件資料。

備註

方法 WriteEvent 會提供包含字串和整數引數組合的多載。 如果這些組合都不符合呼叫的參數,編譯器會使用 EventSource.WriteEvent(Int32, Object[]) 多載,這比其他多載慢很多。 如需詳細資訊,請參閱多載頁面。

在所有情況下, eventid 參數應該大於 0 或小於 65535,或作業中可能會發生錯誤。 如果發生錯誤,如果偵錯工具附加至進程引發事件,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您在發生錯誤的事件來源上有 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫基類 WriteEvent 方法, EventId 傳遞 和 與實作方法相同的引數,類似于下列範例。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

您也可以使用 WriteEventCore 方法來建立自訂多載。

重要

類型為 string 的事件參數不應包含 \0 字元。 這些是不支援的字元,而且可能會導致事件承載剖析器發生問題。

WriteEvent(Int32, String, String, String)

使用所提供的事件識別元和字串引數,寫入事件。

protected:
 void WriteEvent(int eventId, System::String ^ arg1, System::String ^ arg2, System::String ^ arg3);
protected void WriteEvent (int eventId, string arg1, string arg2, string arg3);
protected void WriteEvent (int eventId, string? arg1, string? arg2, string? arg3);
member this.WriteEvent : int * string * string * string -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As String, arg2 As String, arg3 As String)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
String

字串引數。

arg2
String

字串引數。

arg3
String

字串引數。

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, String, Int32, Int32)

使用所提供的事件識別元和引數,寫入事件。

protected:
 void WriteEvent(int eventId, System::String ^ arg1, int arg2, int arg3);
protected void WriteEvent (int eventId, string arg1, int arg2, int arg3);
protected void WriteEvent (int eventId, string? arg1, int arg2, int arg3);
member this.WriteEvent : int * string * int * int -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As String, arg2 As Integer, arg3 As Integer)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
String

字串引數。

arg2
Int32

32 位元整數引數。

arg3
Int32

32 位元整數引數。

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, Int64, Int64, Int64)

使用所提供的事件識別元和 64 位元整數引數,寫入事件。

protected:
 void WriteEvent(int eventId, long arg1, long arg2, long arg3);
protected void WriteEvent (int eventId, long arg1, long arg2, long arg3);
member this.WriteEvent : int * int64 * int64 * int64 -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Long, arg2 As Long, arg3 As Long)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
Int64

64 位元整數引數。

arg2
Int64

64 位元整數引數。

arg3
Int64

64 位元整數引數。

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, Int32, Int32, Int32)

使用所提供的事件識別元和 32 位元整數引數,寫入事件。

protected:
 void WriteEvent(int eventId, int arg1, int arg2, int arg3);
protected void WriteEvent (int eventId, int arg1, int arg2, int arg3);
member this.WriteEvent : int * int * int * int -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Integer, arg2 As Integer, arg3 As Integer)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
Int32

整數引數。

arg2
Int32

整數引數。

arg3
Int32

整數引數。

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, String, String)

使用所提供的事件識別元和字串引數,寫入事件。

protected:
 void WriteEvent(int eventId, System::String ^ arg1, System::String ^ arg2);
protected void WriteEvent (int eventId, string arg1, string arg2);
protected void WriteEvent (int eventId, string? arg1, string? arg2);
member this.WriteEvent : int * string * string -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As String, arg2 As String)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
String

字串引數。

arg2
String

字串引數。

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, String, Int64)

使用所提供的事件識別元和引數,寫入事件。

protected:
 void WriteEvent(int eventId, System::String ^ arg1, long arg2);
protected void WriteEvent (int eventId, string arg1, long arg2);
protected void WriteEvent (int eventId, string? arg1, long arg2);
member this.WriteEvent : int * string * int64 -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As String, arg2 As Long)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
String

字串引數。

arg2
Int64

64 位元整數引數。

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, String, Int32)

使用所提供的事件識別元和引數,寫入事件。

protected:
 void WriteEvent(int eventId, System::String ^ arg1, int arg2);
protected void WriteEvent (int eventId, string arg1, int arg2);
protected void WriteEvent (int eventId, string? arg1, int arg2);
member this.WriteEvent : int * string * int -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As String, arg2 As Integer)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
String

字串引數。

arg2
Int32

32 位元整數引數。

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, Int64, String)

使用所提供的事件識別項、64 位元整數和字串引數,寫入事件。

protected:
 void WriteEvent(int eventId, long arg1, System::String ^ arg2);
protected void WriteEvent (int eventId, long arg1, string arg2);
protected void WriteEvent (int eventId, long arg1, string? arg2);
member this.WriteEvent : int * int64 * string -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Long, arg2 As String)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
Int64

64 位元整數引數。

arg2
String

字串引數。

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(Int64 arg1, string arg2)
{
    base.WriteEvent(2, arg1, arg2);
}

適用於

WriteEvent(Int32, Int64, Int64)

使用所提供的事件識別元和 64 位元整數引數,寫入事件。

protected:
 void WriteEvent(int eventId, long arg1, long arg2);
protected void WriteEvent (int eventId, long arg1, long arg2);
member this.WriteEvent : int * int64 * int64 -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Long, arg2 As Long)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
Int64

64 位元整數引數。

arg2
Int64

64 位元整數引數。

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, Int32, Int32)

使用所提供的事件識別元和 32 位元整數引數,寫入事件。

protected:
 void WriteEvent(int eventId, int arg1, int arg2);
protected void WriteEvent (int eventId, int arg1, int arg2);
member this.WriteEvent : int * int * int -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Integer, arg2 As Integer)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
Int32

整數引數。

arg2
Int32

整數引數。

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(int arg1, int arg2, int arg3)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, Int32, String)

使用所提供的事件識別項、32 位元整數和字串引數,寫入事件。

protected:
 void WriteEvent(int eventId, int arg1, System::String ^ arg2);
protected void WriteEvent (int eventId, int arg1, string arg2);
protected void WriteEvent (int eventId, int arg1, string? arg2);
member this.WriteEvent : int * int * string -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Integer, arg2 As String)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
Int32

32 位元整數引數。

arg2
String

字串引數。

適用於

WriteEvent(Int32, String)

使用所提供的事件識別元和字串引數,寫入事件。

protected:
 void WriteEvent(int eventId, System::String ^ arg1);
protected void WriteEvent (int eventId, string arg1);
protected void WriteEvent (int eventId, string? arg1);
member this.WriteEvent : int * string -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As String)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
String

字串引數。

範例

下列範例示範如何使用這個方法多載來寫入事件。 此程式碼範例是針對 類別提供的較大範例的 EventSource 一部分。

[Event(1, Message = "Application Failure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)]
public void Failure(string message) { WriteEvent(1, message); }
<[Event](1, Message:="Application Failure: {0}", Level:=EventLevel.Error, Keywords:=Keywords.Diagnostic)> _
Public Sub Failure(ByVal message As String)
    WriteEvent(1, message)
End Sub

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, Object[])

使用所提供的事件識別元和引數陣列,寫入事件。

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

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

args
Object[]

物件的陣列。

備註

根據預設,如果呼叫的參數不符合其他方法多載的其中一個,編譯器就會呼叫這個多載。 此多載比其他多載慢很多,因為它會執行下列動作:

  1. 它會配置陣列來保存變數引數。

  2. 它會將每個參數轉換成物件 (,這會導致基本類型配置) 。

  3. 它會將這些物件指派給陣列。

  4. 它會呼叫 函式,然後決定每個引數的類型,以便序列化 ETW。

追蹤低磁片區事件時,此多載的高額外負荷並不重要,因為只有在啟用提供者時才會使用 方法。 不過,對於大量事件,效能額外負荷可能很重要。 您可以藉由使用 方法建立新的更快速多載 WriteEventCore ,以避免使用 EventSource.WriteEvent 大量承載。

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, Int64)

使用所提供的事件識別元和 64 位元整數引數,寫入事件。

protected:
 void WriteEvent(int eventId, long arg1);
protected void WriteEvent (int eventId, long arg1);
member this.WriteEvent : int * int64 -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Long)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
Int64

64 位元整數引數。

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, Int32)

使用所提供的事件識別元和 32 位元整數引數,寫入事件。

protected:
 void WriteEvent(int eventId, int arg1);
protected void WriteEvent (int eventId, int arg1);
member this.WriteEvent : int * int -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Integer)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
Int32

整數引數。

範例

下列範例示範如何使用這個方法多載來寫入事件。 此程式碼範例是針對 類別提供的較大範例的 EventSource 一部分。

[Event(4, Opcode = EventOpcode.Stop, Task = Tasks.Page, Keywords = Keywords.Page, Level = EventLevel.Informational)]
public void PageStop(int ID) { if (IsEnabled()) WriteEvent(4, ID); }
<[Event](4, Opcode:=EventOpcode.Stop, Task:=Tasks.Page, Keywords:=Keywords.Page, Level:=EventLevel.Informational)> _
Public Sub PageStop(ByVal ID As Integer)
    If IsEnabled() Then
        WriteEvent(4, ID)
    End If
End Sub

備註

eventid 應該大於 0 或小於 65535 或作業中可能發生錯誤。 如果發生錯誤,如果您有附加至進程引發事件的偵錯工具,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您有發生錯誤的事件來源上的 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫傳遞 EventId 的基類 WriteEvent 方法,以及與實作方法相同的引數,如下列範例所示。

[Event(2, Level = EventLevel.Informational)]
public void Info1(int  arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, EventSource+EventSourcePrimitive[])

使用提供的事件識別碼和可變數目的事件來源基本類型來寫入事件。

protected:
 void WriteEvent(int eventId, ... cli::array <System::Diagnostics::Tracing::EventSource::EventSourcePrimitive> ^ args);
protected void WriteEvent (int eventId, params System.Diagnostics.Tracing.EventSource.EventSourcePrimitive[] args);
member this.WriteEvent : int * System.Diagnostics.Tracing.EventSource.EventSourcePrimitive[] -> unit
Protected Sub WriteEvent (eventId As Integer, ParamArray args As EventSource.EventSourcePrimitive())

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

args
EventSource.EventSourcePrimitive[]

事件來源基本類型。

備註

這是撰寫事件的 varargs 協助程式。 它會建立陣列並針對所有引數進行方塊處理,因此其效率相當低,因此應該只用于相對罕見的事件 (例如,每秒少於 100 個) 。 如果您的費率比這樣快,請使用 WriteEventCore(Int32, Int32, EventSource+EventData*) 來為您的特定方法簽章建立快速協助程式。 即使您針對罕見事件使用此功能,這項呼叫也應該受到 IsEnabled() 檢查所防護,如此一來,當 EventSource 不在作用中時,就不會進行 varargs 呼叫。

適用於

WriteEvent(Int32, Byte[])

使用所提供的事件識別項和位元組陣列引數,寫入事件。

protected:
 void WriteEvent(int eventId, cli::array <System::Byte> ^ arg1);
protected void WriteEvent (int eventId, byte[] arg1);
protected void WriteEvent (int eventId, byte[]? arg1);
member this.WriteEvent : int * byte[] -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Byte())

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
Byte[]

位元組陣列引數。

備註

eventid 應該大於 0 或小於 65535,否則作業中可能會發生錯誤。 如果發生錯誤,如果偵錯工具附加至進程引發事件,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您在發生錯誤的事件來源上有 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫基類 WriteEvent 方法, EventId 傳遞 和 與實作方法相同的引數,類似于下列範例。

[Event(2, Level = EventLevel.Informational)]
public void Info1(byte[] arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32)

使用所提供的事件識別元,寫入事件。

protected:
 void WriteEvent(int eventId);
protected void WriteEvent (int eventId);
member this.WriteEvent : int -> unit
Protected Sub WriteEvent (eventId As Integer)

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

範例

下列範例示範如何使用這個方法多載來寫入事件。 此程式碼範例是提供給 類別之較大範例的 EventSource 一部分。

[Event(1, Message = "Application Failure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)]
public void Failure(string message) { WriteEvent(1, message); }
<[Event](1, Message:="Application Failure: {0}", Level:=EventLevel.Error, Keywords:=Keywords.Diagnostic)> _
Public Sub Failure(ByVal message As String)
    WriteEvent(1, message)
End Sub

備註

eventid 應該大於 0 或小於 65535,否則作業中可能會發生錯誤。 如果發生錯誤,如果偵錯工具附加至進程引發事件,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您在發生錯誤的事件來源上有 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫基類 WriteEvent 方法, EventId 傳遞 和 與實作方法相同的引數,類似于下列範例。

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

適用於

WriteEvent(Int32, Int64, Byte[])

使用指定的識別項、64 位元整數和位元組陣列引數,寫入事件資料。

protected:
 void WriteEvent(int eventId, long arg1, cli::array <System::Byte> ^ arg2);
protected void WriteEvent (int eventId, long arg1, byte[] arg2);
protected void WriteEvent (int eventId, long arg1, byte[]? arg2);
member this.WriteEvent : int * int64 * byte[] -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Long, arg2 As Byte())

參數

eventId
Int32

事件識別項。 這個值必須介於 0 到 65535 之間。

arg1
Int64

64 位元整數引數。

arg2
Byte[]

位元組陣列引數。

備註

eventid 應該大於 0 或小於 65535,否則作業中可能會發生錯誤。 如果發生錯誤,如果偵錯工具附加至進程引發事件,您可以檢查偵錯工具的輸出資料流程,以取得錯誤來源的詳細資訊。 如果您在發生錯誤的事件來源上有 ETW 接聽程式,您也可以在 ETW 事件資料流程中尋找報告的錯誤。

當您在衍生類別中 EventSource 實作識別為 ETW 事件的方法時。 您必須呼叫基類 WriteEvent 方法, EventId 傳遞 和 與實作方法相同的引數,類似于下列範例。

[Event(2, Level = EventLevel.Informational)]
public void Info1(Int64 arg1, Byte[] arg2)
{
    base.WriteEvent(2, arg1, arg2);
}

適用於