+ public override void DisableNotification ()
+ {
+ if (_notifyResetEvent != null) {
+ _notifyResetEvent.Close ();
+ _notifyResetEvent = null;
+ }
+
+ if (_notifyThread != null) {
+ if (_notifyThread.ThreadState == System.Threading.ThreadState.Running)
+ _notifyThread.Abort ();
+ _notifyThread = null;
+ }
+ }
+
+ public override void EnableNotification ()
+ {
+ _notifyResetEvent = new ManualResetEvent (false);
+ _lastEntryWritten = OldestEventLogEntry + EntryCount;
+ if (PInvoke.NotifyChangeEventLog (ReadHandle, _notifyResetEvent.Handle) == 0)
+ throw new InvalidOperationException (string.Format (
+ CultureInfo.InvariantCulture, "Unable to receive notifications"
+ + " for log '{0}' on computer '{1}'.", CoreEventLog.GetLogName (),
+ CoreEventLog.MachineName), new Win32Exception ());
+ _notifyThread = new Thread (new ThreadStart (NotifyEventThread));
+ _notifyThread.IsBackground = true;
+ _notifyThread.Start ();
+ }
+
+ private void NotifyEventThread ()
+ {
+ while (true) {
+ _notifyResetEvent.WaitOne ();
+ lock (this) {
+ // after a clear, we something get notified
+ // twice for the same entry
+ if (_notifying)
+ return;
+ _notifying = true;
+ }
+
+ try {
+ int oldest_entry = OldestEventLogEntry;
+ if (_lastEntryWritten < oldest_entry)
+ _lastEntryWritten = oldest_entry;
+ int current_entry = _lastEntryWritten - oldest_entry;
+ int last_entry = EntryCount + oldest_entry;
+ for (int i = current_entry; i < (last_entry - 1); i++) {
+ EventLogEntry entry = GetEntry (i);
+ CoreEventLog.OnEntryWritten (entry);
+ }
+ _lastEntryWritten = last_entry;
+ } finally {
+ lock (this)
+ _notifying = false;
+ }
+ }
+ }
+
+ public override OverflowAction OverflowAction {
+ get { throw new NotImplementedException (); }
+ }
+
+ public override int MinimumRetentionDays {
+ get { throw new NotImplementedException (); }
+ }
+
+ public override long MaximumKilobytes {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ public override void ModifyOverflowPolicy (OverflowAction action, int retentionDays)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override void RegisterDisplayName (string resourceFile, long resourceId)
+ {
+ throw new NotImplementedException ();
+ }
+