Cacheing remote event log

  • Thread starter Thread starter Rob Oldfield
  • Start date Start date
R

Rob Oldfield

I have some code that loops through the entires in an event log which works
fine... but very, very slowly. I've found something on the web that claims
that using the copyto method of the entrycollection class to cache the
entries locally will speed things up... but I can't figure out how to get it
to work.

My code currently looks like this...

EventLog1.MachineName = Me.Machine.Text
EventLog1.Log = Me.LogName.Text

For Each ent In EventLog1.Entries
'work on entry
Next

....and I've found this in the help files...

Dim myEventLogEntryArray(myEventLogEntryCollection.Count - 1) As
EventLogEntry
myEventLogEntryCollection.CopyTo(myEventLogEntryArray, 0)
Dim myEnumerator As IEnumerator = myEventLogEntryArray.GetEnumerator()
While myEnumerator.MoveNext()
Dim myEventLogEntry As EventLogEntry = CType(myEnumerator.Current,
EventLogEntry)
Console.WriteLine("The LocalTime the Event is generated is " + _
myEventLogEntry.TimeGenerated)
End While

..... but I can't figure out how to fit them together. Can anyone point me
in the right direction? Thanks.
 
Back
Top