I have read some about GC,Finalizers,Managed & Unmanaged Objects,Disposable pattern @StackOverflow.
Currently,I am quite confused about proper usages of GC,Finalizers,Disposable pattern and managed,unmanaged resources terminology.
IMHO there are lots of misleading answers about the subjects mentioned above.
For instance;
I take this post as an example
The accepted answer for this question imply that if we don't call dispose method of a .net object that implements IDisposable interface by default we won't be able to free unmanaged resources.
I think this is a false statement.First there is a concept confusion between managed and unmanaged resources.In my opinion,
Managed resource: any .NET class that implements the IDisposable interface, like Streams and DbConnections.
Unmanaged resource: the stuffing wrapped in the Managed Resource classes. Windows handles are the most trivial examples.
As @kicsit stated at this post
So I ended up with having idea of that all classes that implement IDisposable interface by default such as pen,streamwriter are managed resources which include unmanaged resources inside.
All difference between calling IDispose method explicitly and letting GC do is that one indirectly signaling to the GC that the object can be cleaned up during the next GC , the latter is completely undeterministic.
However when I have a look of Dataset and Datatable classes ,although they implement IDisposable by default they don't own any unmanaged resources inside. This accepted answer also supports my idea.
Quote from answer
The system.data namespace (ADONET) does not contain unmanaged resources. Therefore there is no need to dispose any of those as long as you have not added yourself something special to it.
So my first idea fails.Having a Disposable by default doesn't necessarily mean that class/object has unmanaged resources inside.
Q1)Is it true?
Q2) If I use a class like streamwriter which includes IDisposable interface by default and not call it.Will GC put it Finalization queue and then call Dispose method respectively ?(I mean StreamWriter.Dispose() method which is equivalent to StreamWriter.Close()
Q3) Is finalization queue takes place if we explicitly implement destructor ?