Everything I have read suggests that if I open files or database connections
or the like, that I should explicitly close those said resources before
making the object subject to GC. This is obviously good programming
technique.
However what happens if this practice is not followed. e.g.
that I have a base object that creates an instance of a filestream and for
arguements sake an instance of a oledb connection.
Both sub objects are opened (one to a file and one to a db) and used to
read/ write data.
Say for instance that I implement the IDisposible interface for the parent
class definition (that instanciates both objects) and within the Dispose()
method I set both object variable references to null (without closing them).
I am under the impression that they will be made available to the GC.
My question is - could data corruption occur to any open data sources that
have been made available to garbage collection OR does (as I suspect) it
simply means that those open resources (open files) will simply be locked
out until the GC destroys them?
Obviously I know that there are several reasons for closing the resources
but I would like to know that corruption is not one of them.
--
Br,
Mark Broadbent
mcdba , mcse+i
=============