My application needs to see all the application event log entries when they enter.
private void eventLog_Application_EntryWritten(object sender, EntryWrittenEventArgs e) {
What I would like to know is what happens if another record is written to EventLog while processing the previous record?
The documentation for EventLog.EntryWritten Event is an example of processing a record written in a record that uses streams (which is why I ask a question).
In this example, they use System.Threading and call the WaitOne() and Set() methods in the AutoResetEvent class, however I'm not sure exactly what this code is designed to achieve.
The documentation states that - WaitOne() "blocks the current thread until the current WaitHandle receives a signal," and that Set() "sets the event status for signaling, allowing one or more waiting threads to continue." I am not sure that part of the flow of this example is intended to be a demonstration, and how this relates to how (or if) it should be applied in practice.
It looks like WaitOne() blocks the stream immediately after recording the record until it is processed, where it will be set to an alarm (using Set() ) before allowing the stream to continue. Is this the only thread for the application?
Most importantly, when my application is not responsible for recording events that need to be read from EventLog, how should this principle be applied? (If, indeed, it needs to be applied.)
What happens if a new Entry written when the application is inside the handler?
source share