Skip to content

Commit 2796648

Browse files
committed
Removed finalizer from reader
1 parent ebf1af4 commit 2796648

1 file changed

Lines changed: 8 additions & 22 deletions

File tree

src/EventLogExpert.Eventing/Readers/EventLogReader.cs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ public sealed partial class EventLogReader(string path, PathType pathType, bool
1515

1616
private bool _disposed;
1717

18-
~EventLogReader()
19-
{
20-
Dispose(disposing: false);
21-
}
22-
2318
public string? LastBookmark { get; private set; }
2419

2520
public void Dispose()
2621
{
27-
Dispose(disposing: true);
28-
GC.SuppressFinalize(this);
22+
if (_disposed) { return; }
23+
24+
if (_handle is { IsInvalid: false })
25+
{
26+
_handle.Dispose();
27+
}
28+
29+
_disposed = true;
2930
}
3031

3132
// Pre-Windows 11, a batch being returned can be maximum of (2 MB of data, batchSize count of events).
@@ -142,19 +143,4 @@ public bool TryGetEvents(out EventRecord[] events, int batchSize = 30)
142143

143144
return bufferUsed - 1 <= 0 ? null : new string(buffer[..^1]);
144145
}
145-
146-
private void Dispose(bool disposing)
147-
{
148-
if (_disposed) { return; }
149-
150-
if (disposing)
151-
{
152-
if (_handle is { IsInvalid: false })
153-
{
154-
_handle.Dispose();
155-
}
156-
}
157-
158-
_disposed = true;
159-
}
160146
}

0 commit comments

Comments
 (0)