So I’m behind in my blogging… Lately, and in the coming weeks, I am working on the new version of our framework at work – so I’m hip-deep in coding. One of the great things about doing component development instead of application development, is the quality standard must be set higher, and you’re also sort of forced to figure out the proper way to do things, or else it will come back to bite you!
Earlier this week, I was finishing this wrapper for IBM MQ access, and I needed to implement IDisposable in my class, to make sure to close down the MQ connection properly. Well, it wasn’t getting called all the time. So when I was researching on why, it turns out there is a proper pattern for implementing IDisposable. See here:
Implementing a Dispose method
When I implemented it this way (and made it thread-safe) – it’s getting called every time now! I’m not perfectly clear on why there is a SECOND overload for Dispose(), but I don’t really have time to dig into it further. This pattern seems to work, consistently.
The point is, don’t go implementing IDisposable all willy-nilly – do it the proper way, as described in the link above!!