EventLog.EnableRaisingEvents Propriedade

Definição

Recebe ou define um valor que indica se recebe EventLogEntryWritten notificações de eventos.

public:
 property bool EnableRaisingEvents { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public bool EnableRaisingEvents { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.EnableRaisingEvents : bool with get, set
Public Property EnableRaisingEvents As Boolean

Valor de Propriedade

true se recebe EventLog notificação quando uma entrada é escrita no registo; caso contrário, false.

Atributos

Exceções

O registo de eventos está num computador remoto.

Exemplos

O exemplo seguinte trata um EntryWritten evento.

using System;
using System.Diagnostics;
using System.Threading;

class MySample{

    public static void Main(){

        EventLog myNewLog = new EventLog();
        myNewLog.Log = "MyCustomLog";

        myNewLog.EntryWritten += new EntryWrittenEventHandler(MyOnEntryWritten);
        myNewLog.EnableRaisingEvents = true;

        Console.WriteLine("Press \'q\' to quit.");
        // Wait for the EntryWrittenEvent or a quit command.
        while(Console.Read() != 'q'){
            // Wait.
        }
    }

    public static void MyOnEntryWritten(Object source, EntryWrittenEventArgs e){
        Console.WriteLine("Written: " + e.Entry.Message);
    }
}
Option Strict
Option Explicit

Imports System.Diagnostics
Imports System.Threading

Class MySample
    Public Shared Sub Main()
        
        Dim myNewLog As New EventLog()
        myNewLog.Log = "MyCustomLog"
        
        AddHandler myNewLog.EntryWritten, AddressOf MyOnEntryWritten
        myNewLog.EnableRaisingEvents = True
        
        
        Console.WriteLine("Press 'q' to quit.")
        ' Wait for the EntryWrittenEvent or a quit command.
        While Char.ToLower(Convert.ToChar(Console.Read()))<>"q"
            ' Wait.
        End While 
    End Sub
    
    Public Shared Sub MyOnEntryWritten(source As Object, e As EntryWrittenEventArgs)
        Console.WriteLine(("Written: " + e.Entry.Message))
    End Sub
End Class

Observações

A EnableRaisingEvents propriedade determina se gera EventLog eventos quando as entradas são escritas no log. Quando a propriedade é true, os componentes que recebem o EntryWritten evento receberão notificação sempre que uma entrada for escrita no registo especificado na Log propriedade. Se EnableRaisingEvents for false, nenhum evento é levantado.

Note

Só pode receber notificações de eventos quando as inscrições forem escritas no computador local. Não pode receber notificações para inscrições escritas em computadores remotos.

Aplica-se a

Ver também