EventProvider 類別

定義

使用此類別 (Class) 來寫入事件。Use this class to write events.

public ref class EventProvider : IDisposable
public class EventProvider : IDisposable
type EventProvider = class
    interface IDisposable
Public Class EventProvider
Implements IDisposable
繼承
EventProvider
實作

備註

若要取用使用WriteEventWriteTransferEvent方法所撰寫的事件,事件必須在資訊清單中定義WriteMessageEvent ; 使用方法撰寫的事件不需要資訊清單。To consume events written using the WriteEvent and WriteTransferEvent methods, the events must be defined in a manifest; events written using the WriteMessageEvent method do not require a manifest.

事件可以包含下列 managed 資料類型:Events can contain the following managed data types:

  • boolbool

  • BooleanBoolean

  • bytebyte

  • charchar

  • decimaldecimal

  • doubledouble

  • floatfloat

  • GuidGuid

  • intint

  • IntPtrIntPtr

  • longlong

  • sbytesbyte

  • shortshort

  • 字串string

  • uintuint

  • UInt64UInt64

如果資訊清單中的事件使用Boolean in 類型,您就無法使用 managed 程式碼中的Boolean資料類型來寫入資料元素。If an event in your manifest uses the Boolean in-type, you cannot write the data element using a Boolean data type in your managed code. 指令Boolean清單中的類型必須有4個位元組的值, Boolean而 managed 程式碼中的資料類型則是1個位元組。The Boolean in-type in your manifest expects a 4-byte value, and a Boolean data type in managed code is 1-byte. 相反地,您必須使用int資料類型來寫入值。Instead, you must use an int data type to write the value. 如果您想要記錄Boolean值,請在資訊清單中使用類型的 UInt8。If you want to log a Boolean value, use the UInt8 in-type in your manifest.

建構函式

EventProvider(Guid)

初始化 EventProvider 類別的新執行個體。Initializes a new instance of the EventProvider class.

方法

Close()

從 ETW 子系統移除提供者的註冊,並釋放所有的 Unmanaged 資源。Removes the provider's registration from the ETW subsystem and releases all unmanaged resources.

CreateActivityId()

建立提供者的唯一活動識別項。Creates a unique activity identifier for the provider.

Dispose()

釋放這個 EventProvider 物件所使用的資源。Releases the resources used by this EventProvider object.

Dispose(Boolean)

釋放這個 EventProvider 物件所使用的資源。Releases the resources used by this EventProvider object.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Finalize()

釋出資源並執行內部清除後,記憶體回收才能回收執行個體。Frees resources and performs internal cleanup before the instance is reclaimed by garbage collection.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetLastWriteEventError()

取得與事件寫入失敗相關的最後一項錯誤。Gets the last error associated with an event write failure.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IsEnabled()

判斷是否有任何工作階段已啟用提供者 (不論用來啟用提供者的層級和關鍵字值為何)。Determines whether any session enabled the provider, regardless of the level and keyword values used to enable the provider.

IsEnabled(Byte, Int64)

判斷是否有任何工作階段正在向提供者要求指定的事件。Determines whether any session is requesting the specified event from the provider.

MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
SetActivityId(Guid)

設定 WriteEvent 方法使用的目前活動識別項。Sets the current activity identifier used by the WriteEvent methods.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
WriteEvent(EventDescriptor, Int32, IntPtr)

寫入事件。Writes an event. 事件資料會指定為記憶體區塊。The event data is specified as a block of memory.

WriteEvent(EventDescriptor, Object[])

寫入事件。Writes an event. 事件資料會指定為物件陣列。The event data is specified as an array of objects.

WriteEvent(EventDescriptor, String)

寫入事件。Writes an event. 事件資料會指定為字串。The event data is specified as a string.

WriteMessageEvent(String)

寫入內含字串做為資料的事件。Writes an event that contains a string as its data.

WriteMessageEvent(String, Byte, Int64)

如果層級和關鍵字值符合工作階段所要求的事件,便會寫入包含字串資料的事件。Writes an event that contains a string as its data if the level and keyword value match the events requested by the session.

WriteTransferEvent(EventDescriptor, Guid, Int32, IntPtr)

在端對端案例中追蹤事件時,將事件連結在一起。Links events together when tracing events in an end-to-end scenario. 事件資料會指定為記憶體區塊。The event data is specified as a block of memory.

WriteTransferEvent(EventDescriptor, Guid, Object[])

在端對端案例中追蹤事件時,將事件連結在一起。Links events together when tracing events in an end-to-end scenario. 事件資料會指定為物件陣列。The event data is specified as an array of objects.

適用於