M
Mehul Patel
Our .Net team have been pondering about using keyword.
We are using streams FileStream and BufferedStream. We use using
keyword at FileStream, and not BufferedStream which wraps FileStream.
So bunch of people said what if exception occurs buffered stream is
not closed.
My Argument is over advantages of using 'Using' keyword.
First Advantage being -- Using used for Dispose (Deterministic
Finalization) to free resources earlier, than later. Dispose and Close
do the same thing. This statement is valid, and is verified by
numerous sources (msdn,books,blogs,newsgroups).
Second Advantage being all objects in using bracket will have priority
in Gargbage collection ! - Is this statement valid?
If file stream is grabage collected, there is no need to use Using
keyword on BufferedStream -- Is this statement valid?.
Pl shed some light on this.
Thanks Very much.
Mehul.
We are using streams FileStream and BufferedStream. We use using
keyword at FileStream, and not BufferedStream which wraps FileStream.
So bunch of people said what if exception occurs buffered stream is
not closed.
My Argument is over advantages of using 'Using' keyword.
First Advantage being -- Using used for Dispose (Deterministic
Finalization) to free resources earlier, than later. Dispose and Close
do the same thing. This statement is valid, and is verified by
numerous sources (msdn,books,blogs,newsgroups).
Second Advantage being all objects in using bracket will have priority
in Gargbage collection ! - Is this statement valid?
If file stream is grabage collected, there is no need to use Using
keyword on BufferedStream -- Is this statement valid?.
Pl shed some light on this.
Thanks Very much.
Mehul.