.NET

Reply
Contributor
Chumplybum
Posts: 25
Registered: ‎12-15-2003
Message 1 of 1 (62 Views)

to dispose or not to dispose

62 Views, 0 Replies
05-28-2006 04:32 PM
hi,

i've been trying to get my head around using 'dispose', but can't quiet seem to do it... i was wondering if someone could explain 'dispose' in lamans terms... for example, if i have the following function:

Public Function IsDrawingOpen(ByVal sPath As String) As Boolean

Dim docDrawing As Document

For Each docDrawing In Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
If docDrawing.Name = sPath Then
docDrawing.Dispose()
Return True
Exit For
End If
Next

Return False

End Function

do i need to use the docDrawings.Dispose() function??? or do i use the docDrawings = nothing (do we use the 'nothing' at all anymore???) when do i use the Implements IDisposable interface??? and then theres the following 2 functions which have caused a bit more confusion...

Public Overloads Sub Dispose() Implements IDisposable.Dispose
'send to OUR implementation of Dispose
Dispose(True)
'return to control to the standardgarbage collector
GC.SuppressFinalize(Me)
End Sub

Protected Overridable Overloads Sub Dispose(ByVal disposing As Boolean)
'override standard Dispose with OUR own
If disposing Then
'clean up global variables
If Not IsNothing(m_UC1) Then m_UC1.Dispose()
If Not IsNothing(m_UC2) Then m_UC2.Dispose()
'clean up COM objects
If Not IsNothing(m_Palette) Then InteropServices.Marshal.ReleaseComObject(m_Palette)
If Not IsNothing(m_PaletteSet) Then InteropServices.Marshal.ReleaseComObject(m_PaletteSet)
End If
End Sub

any help would be great

cheers

mark

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community