IDisposable interface

  • Thread starter Thread starter steve
  • Start date Start date
S

steve

obj = nothing

but just as in vb6, this is automatically done for you when the object goes
out of scope. the only difference is how the garbage collection is done. vb6
decreases the reference count of the object and if the count is 0 then it
immediately tears down the object. vb.net may let the object linger in
memory for a while. it has an optimization algorythm. instead of slowing
your application down by mindlessly killing things off, it looks for the
most efficient time to do so. if that freaks you out, you can obj=nothing
and call gc.collect...vioala.

hth,

steve


| Hi,
|
| does anybody know how to replace the following statement (VB6) in VB.Net?
| Set obj = Nothing.
| I read something about implement IDisposable interface in each class
| I have, but I don't know how to use it.
|
|
 
Marco Roberto said:
does anybody know how to replace the following statement (VB6) in
VB.Net?
Set obj = Nothing.

obj = Nothing
I read something about implement IDisposable interface in each
class I have, but I don't know how to use it.

The links might lead you to what you are looking for:

http://msdn.microsoft.com/library/e...programmingessentialsforgarbagecollection.asp

http://msdn.microsoft.com/library/en-us/vbcon/html/vbconInitializationTerminationOfComponents.asp

http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconFinalizeDispose.asp

http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconUsingConstructorsDestructors.asp


BTW, your system time is wrong.
 
Still, a call to Dispose() might be still required when "obj" is an object
that used unmanaged resources such as files, network connections or GDI
brushes.
 
Hi,

does anybody know how to replace the following statement (VB6) in VB.Net?
Set obj = Nothing.
I read something about implement IDisposable interface in each class
I have, but I don't know how to use it.
 
So, I don't need to set the obj = nothing, because the garbage collection
will take care of it, right?
 
* "Marco Roberto said:
does anybody know how to replace the following statement (VB6) in VB.Net?
Set obj = Nothing.
I read something about implement IDisposable interface in each class
I have, but I don't know how to use it.

If the object isn't needed any more and you want to release its
unmanaged ressources/..., call it's 'Dispose' method if it implements
'IDisposable'.

Do _not_ set the reference to 'Nothing', this will _not_ increase
performance.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
 
Back
Top