How I Implement IDispoosabel Interface?

I am createing a class, through which I will interface of database. I want to use I disposable interface int it.
deepanshu_jouhariAsked:
Who is Participating?
 
SteveH_UKConnect With a Mentor Commented:
Public Class MyClass Implements IDisposable

  Protected disposed As Boolean = False

  Protected Overridable Overloads Sub Dispose( _
            ByVal disposing As Boolean)
            If Not Me.disposed Then
                If disposing Then
                    managedResource.Dispose()
                End If
                ' Add code here to release the unmanaged resource.
                unmanagedResource = IntPtr.Zero
                ' Note that this is not thread safe.
            End If
            Me.disposed = True
  End Sub

#Region " IDisposable Support "
        ' Do not change or add Overridable to these methods.
        ' Put cleanup code in Dispose(ByVal disposing As Boolean).
        Public Overloads Sub Dispose() Implements IDisposable.Dispose
            Dispose(True)
            GC.SuppressFinalize(Me)
        End Sub
        Protected Overrides Sub Finalize()
            Dispose(False)
            MyBase.Finalize()
        End Sub
#End Region

End Class

This example was taken from MSDN.  See http://msdn2.microsoft.com/en-us/library/s9bwddyx.aspx.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.