PC Review


Reply
Thread Tools Rate Thread

class object disposal

 
 
Philip Gray
Guest
Posts: n/a
 
      15th Feb 2004
Hello all,

Simple one - If I have a class that invokes a series of other objects, each
calling their own objects and so on, do I have to explicity dispose of all
of the objects or can I just kill the top level class and all of the
resources will be released?

I'm aware of the resource implications of keeping a lot of objects open,
particularly on the pocketpc, but if I can do this, it'll save me quite a
bit of faffing about.

Thoughts?


 
Reply With Quote
 
 
 
 
Geoff Schwab [MSFT]
Guest
Posts: n/a
 
      16th Feb 2004
Hi Philip,

Dispose does not work like a destructor so any time that you need to Dispose
something, you need to do so explicitly. What I typically do in this type
of situation is have the top level class implement IDisposable and then use
that Dispose to iterate through the objects and call Dispose on each one.
Obviously, you then need to make sure you call Dispose on the top level
class instance.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/p...Q/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
"Philip Gray" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello all,
>
> Simple one - If I have a class that invokes a series of other objects,

each
> calling their own objects and so on, do I have to explicity dispose of all
> of the objects or can I just kill the top level class and all of the
> resources will be released?
>
> I'm aware of the resource implications of keeping a lot of objects open,
> particularly on the pocketpc, but if I can do this, it'll save me quite a
> bit of faffing about.
>
> Thoughts?
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object disposal guidance needed Gale Green Microsoft VB .NET 13 6th Apr 2010 10:53 PM
unsure about object disposal Steve Microsoft C# .NET 2 22nd Oct 2006 05:51 AM
ASP.NET Object Disposal mukulprabhu@gmail.com Microsoft ASP .NET 2 21st Aug 2006 03:05 AM
Com object Garbase disposal Matt MacDonald Microsoft Dot NET Framework 12 26th Sep 2005 08:24 PM
Correct Disposal of Pen Object Chris Microsoft VB .NET 4 18th Jul 2005 05:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:20 AM.