Re: Using Dispose for auditing?
From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 01/19/05
- Next message: Johnny Fugazzi: "Re: Access Network Share from inside an application."
- Previous message: Dave: "How do I determine if text fits into my label or not?"
- In reply to: Marina: "Re: Using Dispose for auditing?"
- Next in thread: Cor Ligthert: "Re: Using Dispose for auditing?"
- Reply: Cor Ligthert: "Re: Using Dispose for auditing?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 19 Jan 2005 12:20:44 -0600
Marina,
> Objects implement IDisposable, so the garbage collector can call Dispose
> on it before collecting it - to make sure all resources were closed prior
> to collection.
Unfortunately the garbage collector never calls Dispose or use IDisposable!
It will call Object.Finalize if your class overrides it, however making the
GC call Finalize might cause your object to hang around in memory
significantly longer then it should (possibly adding pressure to the GC).
The common practice is to have Finalize & Dispose both call
Dispose(boolean).
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconFinalizeDispose.asp
Otherwise I agree with your statements/questions...
Hope this helps
Jay
"Marina" <someone@nospam.com> wrote in message
news:eES0lsZ$EHA.2572@tk2msftngp13.phx.gbl...
> First of all, I am not clear on how figuring out when classes get garbage
> collected are going to help audit changes to a database? Or are you
> auditing something else? Can you please be clear on this?
>
> Also, just because an object had Dispose called on it does *not* mean it
> is garbage collected. Objects implement IDisposable, so the garbage
> collector can call Dispose on it before collecting it - to make sure all
> resources were closed prior to collection. But calling Dispose does
> nothing to make the GC run. Neither does setting the variable to Nothing,
> or any other thing.
>
> The GC will run when it is deemed necessary by the runtime.
>
> "Jonas" <jonas@no.spam.pl> wrote in message
> news:engKckZ$EHA.1400@TK2MSFTNGP11.phx.gbl...
>> Hi!
>>
>> I'm developing the middletiers of an ASP.NET application in VB.NET. I've
>> got a business logic layer in which I would like to perform auditing to a
>> database. Instead of making an auditing call in every method of my
>> classes, would it be a workable way to implement IDisposable in the base
>> class to all the BLL-classes and then in the Dispose method to do the
>> audit call? Do I then have to make sure that all uses of the BLL-classes
>> end with a call to the Dispose-method or can I count on the garbage
>> collector for this?
>>
>> TIA
>>
>> Jonas
>>
>
>
- Next message: Johnny Fugazzi: "Re: Access Network Share from inside an application."
- Previous message: Dave: "How do I determine if text fits into my label or not?"
- In reply to: Marina: "Re: Using Dispose for auditing?"
- Next in thread: Cor Ligthert: "Re: Using Dispose for auditing?"
- Reply: Cor Ligthert: "Re: Using Dispose for auditing?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|