RSS 2.0

Personal Info:

Joe Send mail to the author(s) leads the architecture of an experimental OS's developer platform, where he is also chief architect of its programming language. His current mission is to enable writing large-scale software that is reliable, secure, and scalable by-construction. Before this, Joe founded the Parallel Extensions to .NET project. He has been granted 19 patents, with 49 pending. When not working, Joe enjoys travelling with his wife, writing books, writing music, studying music theory & mathematics, and doing anything involving food & wine.

My books

My music

Disclaimer:
The content of this site are my own personal opinions and do not represent my employer's view in anyway.

© 2012, Joe Duffy

 
 Friday, December 10, 2004

So you may or may not have noticed that System.IO.Stream both has a Close() method and implements IDisposable, meaning it has a Dispose() method, too. (Note: it's explicitly implemented, meaning that to access it you'll need to use an IDisposable typed reference in C#, e.g. as in ((IDisposable)myStream).Dispose().) Stream is an abstract base class, the most common derivitive being FileStream.

Without consulting Reflector, ;) can you answer these questions?

  • What does invoking Close() on an open Stream do?
  • What does invoking Dispose() on an open Stream do?
  • Should you call both at some point in a Stream's lifecycle?
    • If so, when and in what order?
    • If not, why?
  • Can you call only one without having to call the other?
  • Is it weird that there is both a Close() and Dispose() on a single type, or does that seem natural? Based on your understanding of the pattern, do you think we should continue to use it, or is there a better one?

I have a much lengthier post that I'm writing up regarding an internal design debate we're currently involved in - responses will help to shape both the post and the debate. :)

12/10/2004 10:04:53 PM (Pacific Standard Time, UTC-08:00)  #   
Tracked by:
http://www.bluebytesoftware.com/blog/PermaLink.aspx?guid=1fe0f820-5b2b-4b17-82af... [Pingback]

 

Recent Entries:

Search:

Browse by Date:
<December 2004>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

Browse by Category:

Notables: