G
Guest
Hi All,
A small confusion. I have defined a connection class that has
System.Data.IDbConnection as a member variable and implements IDisposable
interface. I have implemented Dispose method to call Dispose method of
IDbConnection. This Dispose method is called from a destructor. In the
dispose method, i also call GC.SuppressFinalize(this) so as to avoid
finalizer. All this was OK untill i came across one article that says - not
to call dispose in finalize on connection/transaction/datareader objects as
these are managed resourses as this eats up system resources. Also is it
really required to implement IDisposable interface for this connection
object???? Simply closing the connection and setting it to null is sufficient
enough (I feel so but need concrete answer and also i consider all .NET
classes as managed resources if im not wrong)???? Also if there is no need to
call Dispose on connection then why the hell microsoft has exposed this
dispose method???? Please help me!!!!
Thanks in advance.
A small confusion. I have defined a connection class that has
System.Data.IDbConnection as a member variable and implements IDisposable
interface. I have implemented Dispose method to call Dispose method of
IDbConnection. This Dispose method is called from a destructor. In the
dispose method, i also call GC.SuppressFinalize(this) so as to avoid
finalizer. All this was OK untill i came across one article that says - not
to call dispose in finalize on connection/transaction/datareader objects as
these are managed resourses as this eats up system resources. Also is it
really required to implement IDisposable interface for this connection
object???? Simply closing the connection and setting it to null is sufficient
enough (I feel so but need concrete answer and also i consider all .NET
classes as managed resources if im not wrong)???? Also if there is no need to
call Dispose on connection then why the hell microsoft has exposed this
dispose method???? Please help me!!!!
Thanks in advance.