Прочитать на английском

Поделиться через


EntryWrittenEventArgs Класс

Определение

Предоставляет данные о событии EntryWritten.

public class EntryWrittenEventArgs : EventArgs
Наследование
EntryWrittenEventArgs

Примеры

В следующем примере демонстрируется EntryWrittenEventArgs конструктор . Он создает пользовательский EventLog объект и записывает в него запись. Затем он создает EntryWrittenEventArgs объект с помощью первой записи в настраиваемом EventLogобъекте . Этот объект используется для уведомления сообщения.

using System;
using System.Diagnostics;

class MySample
{
    public static void Main()
    {
        try
        {
            EventLog myNewLog = new EventLog();
            myNewLog.Log = "MyNewLog";
            myNewLog.Source = "MySource";
            // Create the source if it does not exist already.
            if (!EventLog.SourceExists("MySource"))
            {
                // An event log source should not be created and immediately used.
                // There is a latency time to enable the source, it should be created
                // prior to executing the application that uses the source.
                // Execute this sample a second time to use the new source.
                EventLog.CreateEventSource("MySource", "MyNewLog");
                Console.WriteLine("CreatingEventSource");
                Console.WriteLine("Exiting, execute the application a second time to use the source.");
                // The source is created.  Exit the application to allow it to be registered.
                return;
            }
            // Write an entry to the EventLog.
            myNewLog.WriteEntry("The Latest entry in the Event Log");
            int myEntries = myNewLog.Entries.Count;
            EventLogEntry entry = myNewLog.Entries[myEntries - 1];
            EntryWrittenEventArgs myEntryEventArgs =
                                 new EntryWrittenEventArgs();
            MyOnEntry(myNewLog, myEntryEventArgs);
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception Raised" + e.Message);
        }
    }
    protected static void MyOnEntry(Object source, EntryWrittenEventArgs e)
    {
        if (e.Entry == null)
            Console.WriteLine("A new entry is written in MyNewLog.");
    }
}

Конструкторы

EntryWrittenEventArgs()

Инициализирует новый экземпляр класса EntryWrittenEventArgs.

EntryWrittenEventArgs(EventLogEntry)

Инициализирует новый экземпляр класса EntryWrittenEventArgs с указанной записью в журнале событий.

Свойства

Entry

Возвращает запись, внесенную в журнал.

Методы

Equals(Object)

Определяет, равен ли указанный объект текущему объекту.

(Унаследовано от Object)
GetHashCode()

Служит хэш-функцией по умолчанию.

(Унаследовано от Object)
GetType()

Возвращает объект Type для текущего экземпляра.

(Унаследовано от Object)
MemberwiseClone()

Создает неполную копию текущего объекта Object.

(Унаследовано от Object)
ToString()

Возвращает строку, представляющую текущий объект.

(Унаследовано от Object)

Применяется к

См. также раздел