Click here to Skip to main content
15,906,455 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralBeside something like this book - is there anything more\else ? Pin
Yanshof6-Oct-06 5:46
Yanshof6-Oct-06 5:46 
GeneralRe: Beside something like this book - is there anything more\else ? Pin
Kevin McFarlane7-Oct-06 5:26
Kevin McFarlane7-Oct-06 5:26 
Questionbug in XmlReader ? Pin
Chris Losinger5-Oct-06 5:59
professionalChris Losinger5-Oct-06 5:59 
AnswerRe: bug in XmlReader ? Pin
Guffa5-Oct-06 14:13
Guffa5-Oct-06 14:13 
GeneralRe: bug in XmlReader ? Pin
Chris Losinger5-Oct-06 15:00
professionalChris Losinger5-Oct-06 15:00 
AnswerRe: bug in XmlReader ? Pin
Guffa5-Oct-06 21:13
Guffa5-Oct-06 21:13 
GeneralRe: bug in XmlReader ? Pin
Chris Losinger6-Oct-06 1:46
professionalChris Losinger6-Oct-06 1:46 
GeneralRe: bug in XmlReader ? Pin
Mike Dimmick6-Oct-06 4:31
Mike Dimmick6-Oct-06 4:31 
Chris Losinger wrote:
then why does XmlReader close the file by itself in some situations but not others


Because it has a finalizer which closes the file for you, but this is not deterministic - you cannot predict when this will occur.

Anything which implements IDisposable should be Disposed by the programmer when the object has been finished with. That's the rule I follow. You can use a using block to automatically call Dispose when execution leaves the block - this includes exits due to exceptions as well as normal program execution.

Finalizers run on a single separate finalizer thread, which processes a queue of finalizable objects. An object with a finalizer gets pushed onto the end of the queue when the garbage collector runs, unless GC.SuppressFinalize has been called on the object (this is usually done by the implementation of Dispose). The finalizer thread runs the finalizers asynchronously with respect to the rest of the program. Only when the finalizer has run can the memory that the object was occupying be freed. Best practice is to avoid having objects end up in the finalizer, to reduce the memory load and to avoid synchronization problems with finalizers.

Stability. What an interesting concept. -- Chris Maunder

GeneralRe: bug in XmlReader ? Pin
S. Senthil Kumar6-Oct-06 6:00
S. Senthil Kumar6-Oct-06 6:00 
GeneralRe: bug in XmlReader ? Pin
Mike Dimmick7-Oct-06 1:20
Mike Dimmick7-Oct-06 1:20 
GeneralRe: bug in XmlReader ? Pin
S. Senthil Kumar7-Oct-06 1:36
S. Senthil Kumar7-Oct-06 1:36 
AnswerRe: bug in XmlReader ? Pin
Guffa6-Oct-06 4:32
Guffa6-Oct-06 4:32 
GeneralRe: bug in XmlReader ? Pin
Chris Losinger6-Oct-06 4:49
professionalChris Losinger6-Oct-06 4:49 
GeneralRe: bug in XmlReader ? Pin
Guffa6-Oct-06 10:04
Guffa6-Oct-06 10:04 
GeneralRe: bug in XmlReader ? Pin
Chris Losinger6-Oct-06 10:38
professionalChris Losinger6-Oct-06 10:38 
GeneralRe: bug in XmlReader ? Pin
Guffa6-Oct-06 11:17
Guffa6-Oct-06 11:17 
GeneralRe: bug in XmlReader ? Pin
Chris Losinger6-Oct-06 11:31
professionalChris Losinger6-Oct-06 11:31 
GeneralRe: bug in XmlReader ? Pin
Guffa6-Oct-06 12:18
Guffa6-Oct-06 12:18 
GeneralRe: bug in XmlReader ? Pin
Chris Losinger6-Oct-06 12:31
professionalChris Losinger6-Oct-06 12:31 
GeneralRe: bug in XmlReader ? Pin
Guffa6-Oct-06 13:17
Guffa6-Oct-06 13:17 
GeneralRe: bug in XmlReader ? Pin
Chris Losinger6-Oct-06 16:42
professionalChris Losinger6-Oct-06 16:42 
GeneralRe: bug in XmlReader ? Pin
Guffa7-Oct-06 1:47
Guffa7-Oct-06 1:47 
GeneralRe: bug in XmlReader ? Pin
Chris Losinger7-Oct-06 3:50
professionalChris Losinger7-Oct-06 3:50 
GeneralRe: bug in XmlReader ? Pin
Colin Angus Mackay10-Oct-06 1:05
Colin Angus Mackay10-Oct-06 1:05 
AnswerRe: bug in XmlReader ? [modified] Pin
Dave Kreskowiak6-Oct-06 4:39
mveDave Kreskowiak6-Oct-06 4:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.