Ereignisbehandlung für das Schreiben eines EventLog-Eintrags
using System;
using System.Diagnostics;
using System.Threading;
class MySample{
// This member is used to wait for events.
static AutoResetEvent signal;
public static void Main(){
EventLog myNewLog = new EventLog();
myNewLog.Log = "MyCustomLog";
myNewLog.EntryWritten += new EntryWrittenEventHandler(MyOnEntryWritten);
myNewLog.EnableRaisingEvents = true;
signal = new AutoResetEvent(false);
signal.WaitOne();
}
public static void MyOnEntryWritten(object source, EntryWrittenEventArgs e){
signal.Set();
}
}
Kommentare zum Snippet