J
Jim Bancroft
Hi,
I have a couple of classes that implement the Dispose() method. One class
creates an instance of and calls methods on the other, so it's a sort of
parent-child relationship I suppose.
My question is, what happens if my child class calls its Dispose method at
the end of one of its try-catch-finally blocks? In step-by-step terms, I'm
wondering about this: the parent class creates a child and calls the
child's method ABC(). The child in turn calls its Dispose() method at the
end of ABC()'s finally block. I assume the child is now out of reach and
subject to garbage collection, but I could be wrong.
Now, what if the parent calls another one of the child's methods, maybe
method XYZ()? Will it have an invalid object at that point?
I have a couple of classes that implement the Dispose() method. One class
creates an instance of and calls methods on the other, so it's a sort of
parent-child relationship I suppose.
My question is, what happens if my child class calls its Dispose method at
the end of one of its try-catch-finally blocks? In step-by-step terms, I'm
wondering about this: the parent class creates a child and calls the
child's method ABC(). The child in turn calls its Dispose() method at the
end of ABC()'s finally block. I assume the child is now out of reach and
subject to garbage collection, but I could be wrong.
Now, what if the parent calls another one of the child's methods, maybe
method XYZ()? Will it have an invalid object at that point?