Article View: borland.public.csharpbuilder.language.csharp
Article #231Where to cleanup an object instance
From: Francois PIETTE [ICS - MidWare]
Date: Tue, 25 Jul 2006 18:48
Date: Tue, 25 Jul 2006 18:48
19 lines
1718 bytes
1718 bytes
I'm porting Delphi code to C#. In a Delphi class, you cleanup a class instance from the destructor. But in C#, there is no destructor. So where do I put cleanup code (such as closing database connection) ? Should I put the cleanup code in Finalize() ? Can I explicitely call Finalize() when I'm done with an object ? I don't want the cleanup code to be called when the object instance is garbage collected. I want it to be executed when I'm done with the object instance. Maybe a better design is to create my Cleanup() method and call it from where I used to call Delphi's destructor ? Any advice appreciated. -- francois.piette@overbyte.be The author for the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be
Technical Details
Message-ID:
<44c66807@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,57d58bae5e2b1da0,start X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Francois PIETTE [ICS - MidWare]" <francois.piette@overbyte.be> Newsgroups: borland.public.csharpbuilder.language.csharp Subject: Where to cleanup an object instance Date: Tue, 25 Jul 2006 20:48:44 +0200 Lines: 22 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 81.244.62.124 Message-ID: <44c66807@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1153853447 81.244.62.124 (25 Jul 2006 11:50:47 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail