.NET

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

to dispose or not to dispose

101 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.