Article View: borland.public.csharpbuilder.language.csharp
Article #312Re: Sharing object with notification on deletion, "best practice" ?
From: Craig Stuntz TeamB
Date: Mon, 25 Jul 2005 17:51
Date: Mon, 25 Jul 2005 17:51
19 lines
1902 bytes
1902 bytes
OD wrote: > Under Delphi I show a few solutions, by example using a notification > scheme. But under .NET and C#, destructors are not often used, > object are not freed, they are just "forgotten" and the GC make the > job, destructor are not always called, etc. > > So, what's the best way to notify instance of Class B that a P object > stored in A has been deleted ? You could use either IDisposable or WeakReference. If it's nothing more than forgetting the instance, I'd probably choose the latter. If you have to do something additional you might want to use IDisposable. -- Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz How to ask questions the smart way: http://www.catb.org/~esr/faqs/smart-questions.html
Technical Details
Message-ID:
<42e526b1$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<mn.cca47d57c87d5b9d.18651@0e-naxos.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,342976a6aefaf8ae X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Craig Stuntz [TeamB]" <craig_stuntz@nospam.please [a.k.a. acm.org]> Subject: Re: Sharing object with notification on deletion, "best practice" ? Newsgroups: borland.public.csharpbuilder.language.csharp References: <mn.cca47d57c87d5b9d.18651@0e-naxos.com> Organization: Vertex Systems Corporation User-Agent: XanaNews/1.17.5.7 X-Face: "huzh55Xi]!ZNni78>a*5+).`SK?<^q2MlHk-C]Z2M9T@\J5ZCB$95Ey+s"XQuhGFA[eutZ:0^AV!Q;t>gE`1-=8d;HZ6~*o1dH<X9\b$!|(}+I'!Xq)@3Op}%0ArW&nf'Qh*EwR NNTP-Posting-Host: 24.106.104.204 Message-ID: <42e526b1$1@newsgroups.borland.com> Date: 25 Jul 2005 10:51:45 -0700 X-Trace: newsgroups.borland.com 1122313905 24.106.104.204 (25 Jul 2005 10:51:45 -0700) Lines: 19 X-Authenticated-User: cstuntz Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail