Click here to Skip to main content
15,909,747 members
Home / Discussions / C#
   

C#

 
GeneralRe: Trouble in parameter! Pin
Colin Angus Mackay10-Jan-07 10:20
Colin Angus Mackay10-Jan-07 10:20 
GeneralRe: Trouble in parameter! [modified] Pin
Alaric_10-Jan-07 10:42
professionalAlaric_10-Jan-07 10:42 
QuestionCheck for Filesystem Type NTFS / FAT .NET 1.1 [modified] Pin
Thomas Mihatsch10-Jan-07 3:49
Thomas Mihatsch10-Jan-07 3:49 
AnswerRe: Check for Filesystem Type NTFS / FAT Pin
jarellan10-Jan-07 3:51
jarellan10-Jan-07 3:51 
QuestionStreamWriter reuse? Pin
jarellan10-Jan-07 3:35
jarellan10-Jan-07 3:35 
AnswerRe: StreamWriter reuse? Pin
Guffa10-Jan-07 4:00
Guffa10-Jan-07 4:00 
GeneralRe: StreamWriter reuse? Pin
jarellan10-Jan-07 4:16
jarellan10-Jan-07 4:16 
GeneralRe: StreamWriter reuse? Pin
Colin Angus Mackay10-Jan-07 4:30
Colin Angus Mackay10-Jan-07 4:30 
jarellan wrote:
Is there a file stream oriented object more specialized in reusability?


It has been several years since I last used C++, but I don't think you reused the file resources in C++ either. The when you re-opened a stream you would most likely get a different file handle internally anyway. It was just the class's public interface that made it appear otherwise.

Also, when you Dispose an object in C# (or close a stream) it tells the garbage collector to suppress the finaliser (the .NET equivalent of a destructor). The Finaliser is a safety mechanism in case the managed .NET object goes out of scope while holding onto unmanaged resources, like a file handle. Because the Dispose method and Close method cleans up the unmanaged resources the object can be flagged as not needing to run the finalizer any more. This speeds up garbage collection.

It is possible for an object to call ReRegisterForFinalizer if it needs to, but the documentation does list this very important caveat "Calling the ReRegisterForFinalize method does not guarantee that the garbage collector will call an object's finalizer." [my emphasis]. Without the gurarantee the application could leak memory all over the place if the developer of the client code forgot to call Dispose or Close, or was not disciplined into ensuring that it was called.

I hope this helps.


Upcoming Scottish Developers events:
* Glasgow: Tell us what you want to see in 2007


My: Website | Blog | Photos

GeneralRe: StreamWriter reuse? Pin
jarellan10-Jan-07 4:56
jarellan10-Jan-07 4:56 
AnswerRe: StreamWriter reuse? Pin
Guffa10-Jan-07 13:56
Guffa10-Jan-07 13:56 
GeneralRe: StreamWriter reuse? Pin
jarellan10-Jan-07 20:23
jarellan10-Jan-07 20:23 
Questionreading characters C# Pin
netJP12L10-Jan-07 3:32
netJP12L10-Jan-07 3:32 
AnswerRe: reading characters C# Pin
Not Active10-Jan-07 3:40
mentorNot Active10-Jan-07 3:40 
AnswerRe: reading characters C# Pin
Martin#10-Jan-07 3:42
Martin#10-Jan-07 3:42 
AnswerRe: reading characters C# [modified] Pin
Guffa10-Jan-07 4:02
Guffa10-Jan-07 4:02 
GeneralRe: reading characters C# Pin
netJP12L10-Jan-07 8:27
netJP12L10-Jan-07 8:27 
GeneralRe: reading characters C# Pin
Alaric_10-Jan-07 8:46
professionalAlaric_10-Jan-07 8:46 
AnswerRe: reading characters C# Pin
Guffa10-Jan-07 13:23
Guffa10-Jan-07 13:23 
GeneralRe: reading characters C# Pin
Alaric_10-Jan-07 14:20
professionalAlaric_10-Jan-07 14:20 
GeneralRe: reading characters C# Pin
Guffa10-Jan-07 20:47
Guffa10-Jan-07 20:47 
GeneralRe: reading characters C# Pin
Alaric_11-Jan-07 1:00
professionalAlaric_11-Jan-07 1:00 
GeneralRe: reading characters C# Pin
netJP12L15-Jan-07 4:54
netJP12L15-Jan-07 4:54 
QuestionDMVR Image stream? Pin
Gavin Roberts10-Jan-07 2:53
Gavin Roberts10-Jan-07 2:53 
AnswerRe: DMVR Image stream? Pin
ednrgc10-Jan-07 4:32
ednrgc10-Jan-07 4:32 
GeneralRe: DMVR Image stream? Pin
Gavin Roberts10-Jan-07 4:40
Gavin Roberts10-Jan-07 4:40 

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.