in the very first MS code snippet, it says to clean up managed resources, using the following way:
managedResource.Dispose();
managedResource = null;
assuming managedResource has a Dispose method which again set some managed resources to null, it would be
class managedResource
{
protected virtual void Dispose(bool disposing)
{
anotherUnmanagedRes.Dispose();
anotherUnmanagedRes = null;
}
}
meaning: it will only set the managed resources' references to null in a chain.
If Im correct, that means, we just set the objects ready for GC rather than destroying it right there. Alternatively we can set the managed resources to null only (without implementing Dispose()) if we have managed resources if this is the case, can't we?
Any feedbacks would be really appreciated on this.