Disposing an object doesn't automatically dispose all of its properties that are IDisposables
. All it does is execute the Dispose
method, what the object does then is up to the developer.
When an object of a class is disposed it should dispose all owned resources that implement the IDisposable
interface. In your case you dispose an object that could very well be still in use.
I think the article from Stephen Cleary about IDisposable: What Your Mother Never Told You About Resource Deallocation explains about disposing objects and about the difficulties and problems that can arise in some circumstances.