Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2003, 06:28 PM
DKS DKS is offline
Registered User
 
Join Date: Jul 2003
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?

Thanks
 
Old July 22nd, 2003, 06:44 PM
Registered User
 
Join Date: Jul 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






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





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