EventLogWatcher 類別

定義

讓您訂閱內送事件。Allows you to subscribe to incoming events. 每次所需的事件發行至事件記錄檔時,就會引發 EventRecordWritten 事件,並會執行處理這個事件的方法。Each time a desired event is published to an event log, the EventRecordWritten event is raised, and the method that handles this event will be executed.

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

範例

如需使用此類別的範例程式代碼,請參閱如何:訂閱事件記錄檔中的事件。For example code using this class, see How to: Subscribe to Events in an Event Log.

備註

這個類別的實例是從EventLogQuery指定事件訂閱之查詢的物件所建立。The instances of this class are created from EventLogQuery objects, which specify a query for the event subscription. 當所記錄之事件符合查詢中表示的準則時,就會引發 EventRecordWritten 事件。When an event is logged that matches the criteria expressed in the query, then the EventRecordWritten event is raised.

建構函式

EventLogWatcher(EventLogQuery)

藉由指定事件查詢,初始化 EventLogWatcher 類別的新執行個體。Initializes a new instance of the EventLogWatcher class by specifying an event query.

EventLogWatcher(EventLogQuery, EventBookmark)

藉由指定事件查詢以及做為查詢開始位置的書籤,初始化 EventLogWatcher 類別的新執行個體。Initializes a new instance of the EventLogWatcher class by specifying an event query and a bookmark that is used as starting position for the query.

EventLogWatcher(EventLogQuery, EventBookmark, Boolean)

藉由指定事件查詢、做為查詢開始位置的書籤,以及判斷是否要讀取事件記錄檔中現有事件的布林值,初始化 EventLogWatcher 類別的新執行個體。Initializes a new instance of the EventLogWatcher class by specifying an event query, a bookmark that is used as starting position for the query, and a Boolean value that determines whether to read the events that already exist in the event log.

EventLogWatcher(String)

藉由指定事件記錄檔的名稱或路徑,初始化 EventLogWatcher 類別的新執行個體。Initializes a new instance of the EventLogWatcher class by specifying the name or path to an event log.

屬性

Enabled

取得或設定值,指出這個物件是否會開始傳遞事件至事件委派。Gets or sets a value that indicates whether this object starts delivering events to the event delegate.

方法

Dispose()

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

Dispose(Boolean)

釋放這個物件所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by this object, and optionally releases the managed resources.

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

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

(繼承來源 Object)
GetType()

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

(繼承來源 Object)
MemberwiseClone()

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

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

事件

EventRecordWritten

允許設定委派 (事件處理常式方法),每次發行符合這個物件之事件查詢中所指定準則的事件時,都會呼叫這個委派。Allows setting a delegate (event handler method) that gets called every time an event is published that matches the criteria specified in the event query for this object.

適用於

另請參閱