Home » Archive by category "Uncategorized"

Hello from nadiacomanici.com!

Hi everybody!

As you may have noticed, I have my own domain! I still have some work to do in order to import and setup the site as I want, but in a few days everything should be in place. Of course, a few days starting from next week, because I am leaving on holiday tomorrow, so I don’t really have a lot of free time right now.

So, until then, all the best to all of you!


Today I encountered a very interesting problem : If I have a class that implements the IDisposable interface, when is the Dispose() method called?

Well, I initially thought that the Garbage Collection (GC) calls it, but actually Dispose() is a method like any other and should be called explicitly, by the developer!

Well, than what is the relationship between the CG and Dispose()? First of all, Dispose() is not a destructor, so it can’t free the object’s memory, instead it should be used in order to clean-up the unmanaged resources (because the GC has no knowledge of anything not allocated on the managed heap), like database connections, bitmaps, opened streams or files.

Be careful, because Dispose() is not thread-save and can be called by two threads in the same time on the same object! A very nice answer and more details are given on Chris Lyon’s WebLog