Open
Description
As we can see in the implementation, there is no call to Dispose(false)
. In general, there should be ~EventLogWatcher
to call it.
The for loop is unreachable and eventBuffer
would never be released.
Another thing that is worth noting is there is a same piece of code (aka. for loop) at the end of StopSubscribing()
method.
Maybe they are duplicated.
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
StopSubscribing();
return;
}
for (int i = 0; i < _numEventsInBuffer; i++)
{
if (_eventsBuffer[i] != IntPtr.Zero)
{
NativeWrapper.EvtClose(_eventsBuffer[i]);
_eventsBuffer[i] = IntPtr.Zero;
}
}
_numEventsInBuffer = 0;
}