Re: " //Clean Up managed resources " f&*ck



On 19 Maj, 11:43, Moty Michaely <Moty...@xxxxxxxxx> wrote:
On May 19, 12:33 am, "Koliber (js)" <profesor_kinb...@xxxxxxxxxxxxxx>
wrote:

If sql connection is managed resource
why dispose if called from finaliser in pattern above
should leave it untouched?

The finalizer is called by the GC. Implementing a finalizer is the
only way to code things that needs to be done at instance collection
time (such as releasing internal unmanaged resources). Since Dispose
methods is responsible for cleaning resources, the finalizer code
usually calls the Dispose method.
Therefore, you are right - it's there to guarantee object disposal if
not called manually. But, again, the GC is not deterministic. The
finalizar can practically call the finalizer 10 minutes after it
really got pinned off... Therefore, manual disposal is a best practice
to make sure that unmanaged resources will not be held for 10 minutes,
for nothing....

And if sql connection is unmanaged resource
what the hell is managed resource and how
it can be explicite free'd? :(

Quote: "In Microsoft Windows terminology, managed code is computer
instructions - that is, "code" - executed by a CLI-compliant virtual
machine, such as Microsoft's .NET Framework Common Language Runtime,
or other CLI implementations from The Mono Project or the DotGNU
Project."

Taken from:http://en.wikipedia.org/wiki/Managed_code

Therefore, SqlConnection is a managed code that uses unmanaged
resources.

Hope this clears things..

Moty

Sorry but not at all :( - my question I am putting all the time is
not
about managed code (all things you said i do know)
it is about 'managed resource'. What the hell it is? and how is
method
of clearing it? (see dispose pattern in 1st post there are two areas
for cleaning code one for unmanaged resources (clear for me i think -
like
sql connection) and second for the managed resource cleaning i do not
know
what it is.

--
test

.



Relevant Pages

  • Re: Is Dipose( ) a contractual obligation, if you provide one?
    ... You're at least saying "it'd be a really good idea for you to call Dispose ... relinquish its resources at an explicit point." ... and the finalizer should take care. ... a UEntity unmanaged object requires a USession unmanaged ...
    (microsoft.public.dotnet.languages.vc)
  • Re: " //Clean Up managed resources " f&*ck
    ... Since Dispose ... methods is responsible for cleaning resources, the finalizer code ... it is about 'managed resource'. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: " //Clean Up managed resources " f&*ck
    ... time (such as releasing internal unmanaged resources). ... Since Dispose ... methods is responsible for cleaning resources, the finalizer code ... it is about 'managed resource'. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Question on implementing IDisposable
    ... have dealth with the unmanaged resources and before you take your ... This class does not implement a finalizer ... The overloaded Dispose which takes a bool argument should be made ... Then, the base class can implement IDispose, so ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How much do you leave to VB.Net GARBAGE COLLECTION???
    ... as necessary due to the Garbage Collection capability. ... those that implement IDisposable and have a Dispose method. ... From the Finalizer, ... asynchronously and unmanaged resources might not be freed in a timely ...
    (microsoft.public.dotnet.languages.vb)