IDisposable Part 2 – Subclass from an IDisposable class
For part 2 of my series on IDisposable, I’m going to focus on subclassing from our IDisposable resource. We will build on our LicenseGenerator class from Part 1, extending it with some additional functionality.
When subclassing from an IDisposable resource, there are two possibilities for requirements in handling IDisposable correctly. If we are not introducing any other unmanaged or managed resources that need to be disposed, we can handle this very simply.
IDisposable Part 1 – Releasing Unmanaged Resources
IDisposable, what is it, why is it needed? In this part of our series on IDisposable, we’re going to focus on the initial, and primary use case of IDisposable – wrapping unmanaged resources…
IDisposable – The oft misunderstood and misused interface
During my time following Stack Overflow, one of the most common misconceptions I’ve run across has been confusion in the understanding of IDisposable.
For example, the author of this post confused IDisposable with a way to explicitly free memory. This question is related to the way using works, how and when to use the using statement. Here a poster was asking about trying to force the GC to collect earlier…
There are many blog posts and articles online which do an excellent introduction to IDisposable, but most focus on just one aspect of this interface. In my view, it is too complex of a subject to be tackled in a single article. To that end, I’m going to break this into a series, each post describing one aspect of using IDisposable in detail. Hopefully, this will be a way to clear up many of the misconceptions of explicit resource handling in C# and .NET.