Diposing as technique:
Nutshell:
For managed resources it is irrelevant when they are removed from memory. Some time between the last reference vanishing and the end of the programm they will be collected, details are beyond the programemrs view.
However there are also umanaged resourcs - especially file handles, Network Connections and the like. Those are designed to be released upon collection (Finalize).
The problem is that you do not know when something is garbage collected. So that file handle object might not have been closed by the time you need the file at another place.
So you call dispose to return all unmanaged resources "now". You call it jsut before you let the last reference to that object vanish. Don't call it for something you still need.
Let's talk about MVVM: http://ift.tt/1fpEgna Please mark post as helpfull and answers respectively.
No comments:
Post a Comment