Nederlandstalig? U woont in Vlaanderen? Bezoek Vlakbij.me en kom in contact met de beste handelaars in je buurt
Disposing of the IDisposable implementation
Everytime I need to implement the IDisposable interface I have to lookup the recommended way of doing so. That in itself is a bad sign, so I figured I might as well get rid of this by putting the implementation in a reusable base class, based on the officially recommended way:
So now I can simply inherit from Disposable, and I just need to implement the two abstract methods. Here's a made up example to illustrate this:
Obviously, you can't use the Disposable base class if you're already inheriting from another base class so in that case you'd still have to implement the IDisposable interface.
Update: Here's a thread-safe version of this idea.
comments powered by Disqus