SqlDataAdapter and finalization

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,

I had some code that forgot (or should I say I forgot) to
call Dispose on a SqlDataAdapter, so I thought it will be
okay since SqlDataAdapter inherits via Component so the
inherited Dispose/Finalize pattern would be picked up.

However, after poking around with a decompiler I notice
that within the constructor of SqlDataAdapter the call to
GC.SuppressFinalize() is made so because my code forgot
to call Dispose, the cleanup code will never be called
via the overriden Finalizer in Component.

Does anyone haveany thoughts on the rationale behind the
SqlDataAdpater choosing to call GC.SuppressFinalize() in
its constructor.

Colin
 
Hi,

Maybe because it doesn't use non-managed resources.
One should never touch managed objects in destructor...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top