let's suppose I've a class that inherits from the log4net.Appender.FileAppender
type because I've to provide some custom log functionalities and that class owns an unmanaged resource.
In the below code I report the definition of the class and the implementation of the Disposable pattern.
public class MyLogFileAppender : FileAppender, IDisposable
{
private IDisposable _myUnmanagedResource;
#region Other methods used for flushing and so on are here.
#endregion
public void Dispose()
{
Dispose(true);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_myUnmanagedResource?.Dispose();
}
}
}
My question is: how and when call the Dispose method? I would be nice if it's called by the underlying log4net system but I think that is not the case and I should manually invoke it.