Article View: borland.public.csharpbuilder.language.csharp
Article #506Dispose notifications?
From: Theo Bebekis
Date: Thu, 04 Nov 2004 10:43
Date: Thu, 04 Nov 2004 10:43
40 lines
2244 bytes
2244 bytes
Hi
Lets suppose I have an IDisposable class implemented.
The class has references to unmanaged resources.
Then many instances of that class are created in
many different places of the application.
In some cases, the code that creates such an instance
may insert the newly created object into a global list.
The list is maintained by another object not related to
the one that created the IDisposable object.
Is it possible for the owner of that list to receive
notifications automatically, when such an object is disposed,
by calling its Dispose(), in order to remove it from the list?
In other words I just need the kind of functionality the
VCL provides through TComponent.Notification,
TComponent.FreeNotification and TComponentList.
I think it can be done by defining an OnDisposeNotification
event by that IDisposable class and then when the object
is added to the list, hook into that event. What do you think?
Or is that functionality already in the framework?
--
Regards
Theo
------------------------
Theo Bebekis
Thessaloniki, Greece
------------------------
Greek_Delphi_Prog : a Delphi Programming mailing list in Greek at
http://groups.yahoo.com/group/Greek_Delphi_Prog
atla_custom : a Unisoft Atlantis Customization mailing list at
http://groups.yahoo.com/group/atla_custom
------------------------
Technical Details
Message-ID:
<418a07ba$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,27a6c77a0bac7ca2,start X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 04 Nov 2004 12:43:21 +0200 From: Theo Bebekis <teo@thinx.gr> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040803 X-Accept-Language: el, en-us, en MIME-Version: 1.0 Newsgroups: borland.public.csharpbuilder.language.csharp Subject: Dispose notifications? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 62.103.78.2 Message-ID: <418a07ba$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1099564986 62.103.78.2 (4 Nov 2004 02:43:06 -0700) Lines: 40 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail