title: Iterating through Event Log Entry Collection, IndexOutOutOfBoundsException
body: <p>in a service application I am iterating through the Windows application event log to parse Events in order react depanding on the entry message.
  In the case that the event log is full (Windows usually makes sure there is enough space by deleting old entries - this is configurable in the <code>eventvwr.exe</code> settings), the service always runs into an <code>IndexOutOfBoundsException</code> while iterating through the <code>EventLog.Entries</code> collection. No matter how I iterate (for-loop, using the collections enumerator, copying the collection into an array, ...), I can't seem to get rid of this ´bug´.</p>
  
  <p>Currently, I ensure that the log is not full in order to keep the service running by regularly deleting the last few item by parsing the event log file and deleting the last few nodes (Don't beat me up, I couldn't find a better alternative...).</p>
  
  <p>How can I iterate through the collection without trying to access already deleted entries?</p>
  
  <p>Is there probably a more elegant method? I am only trying to acces the logs written during the last <code>x</code> seconds (even LINQ failed to select those when the log is full - same exception), could this help?</p>
  
  <p>Thanks for any advice and hints</p>
  
  <p>Frank</p>
  
  <p><em>Edit: I forgot to mention that my assumption is the loops are accessing entries which are being deleted during iteration by Windows. Basically that is why I tried to clone the collection. Is there perhaps a way to lock the collection for a small amount of time for just my application?</em></p>