Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

How to dispose a custom class object

$
0
0

Hi, I have a custom class who doesn't inherit any system component object.

How should I dispose an object of this class?

My class does not inherit a dispose method, so how should I create one?
I have read the dispose finalize pattern that suggests to use IDisposable. In this pattern we have managed resource.dispose method.

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

In my case I have to write my own commands to destroy the object. So how do I destroy an object??  Should I set all the properties to nothing? Inside my class in can't say Me=nothing for example

So do I say to an object to destroy itself?


Viewing all articles
Browse latest Browse all 1710

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>