I must add some Dispose code to a class that inherits from a class that already implements IDisposable so I tried to do an Override of the Dispose method but I have not available the disposedValue because it is declared as private.
How can I add the new Dispose statements?
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not disposedValue Then
If disposing Then
''# ...
End If
End If
disposedValue = True
End Sub
Thanks in advance!
EXTENDED INFO: I think that I should implement the same logic present at the base class at the inheritor. Am I right?
MORE INFO: I am using the snipet that Vb.Net automatically writes when you declare that a class implements IDisposable.
You could make a separate
disposedValuefield in the derived class.However, you should probably name it
isDisposed.Note that all classes in the FCL will not do anything if you call
Disposetwice, so there isn’t necessarily anything wrong with taking out that logic and disposing multiple times. Obviously, this depends on what you’re doing inDispose; you should check.Make sure to call
MyBase.Dispose(disposing).