I have got some code which should read errors from all paths in the eventviewer. It all works fine with the code below.
foreach (var log in EventLog.GetEventLogs(Environment.MachineName))
{
log.Entries
.Cast<EventLogEntry>()
.Where(x => x.EntryType == EventLogEntryType.Error && x.TimeWritten > DateTime.Now.AddHours(-1))
.ToList()
.ForEach(x =>
{
list.Add(new LogEntry(x, log.LogDisplayName, ItemStatus.Error));
});
}
That usually takes up less than two seconds.
Now my Problem is that when i use another machine instead of Environment.MachineName
, this process takes up 5-20 minutes.
Is there a way to speed this up?
Thanks
Avoiding LINQ didn't affect my results a lot.