Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 16th, 2003, 06:28 PM
DKS DKS is offline
Registered User
Join Date: Jul 2003
Location: Glendale, WI, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default General Question about Dispose

First of all let me say GREAT BOOK. Thanks to all involved.

Here's a question: in C# you use "using" in VB you specifically call dispose. The first time this comes up is in Chapter 5. That's great, I understand what dispose does, but what I'm not clear about is the objects that are chosen to dispose. In the Chapter 5 code dispose is called in the functions that use datasets. Why isn't dispose called to get rid of parameters or datareaders for example? How do you determine which objects are disposed by you and which are disposed by the framework?

  #2 (permalink)  
Old July 22nd, 2003, 06:44 PM
Registered User
Join Date: Jul 2003
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Dispose is a method you call to dispose of 'valuable' resources (files, sockets, etc.). Dispose is also used with managed objects that have references to unmanaged objects. With these types of scenarios, the user of the class needs to be able to explictly 'free' these resources (since you don't want to wait for the garbage collector to free them - who knows when that will happen). So, Dispose is the standard way to do this.

Someone who is creating this type of class is supposed to implement the IDisposable interface. This interface has one method called Dispose(). So, if you see a class that inherits from IDisposable, you know you should call Dispose() on it as soon as you're done with it. Note that calling Dispose does not destroy/garbage collect the object. Although, it will probably put the object in an unstable/unusable state. You will usually get an ObjectDisposedException thrown if you try to use the object after calling Dispose().

Hope this helps.

Tim Rogers


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
General SELECT question rsearing SQL Server 2005 1 January 16th, 2007 12:01 PM
General Question About c++ madeebmir C++ Programming 0 August 15th, 2006 10:48 AM
Very general question merianos VB How-To 4 August 1st, 2006 12:24 PM
Question : Dispose mike_abc Pro VB.NET 2002/2003 1 May 14th, 2005 02:17 PM
General Question stu9820 ASP.NET 1.0 and 1.1 Basics 2 September 23rd, 2003 03:36 PM

All times are GMT -4. The time now is 09:07 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.