-----Original Message-----
Can we call garbage collector explicitly in .nert
framework?
.
Yes, just call GC.collect(gen). This collect generations 0
to gen where gen <= 2, there are 3 generations supported
in current version of the framework. You can also call
GC.collect() without arguments, this is eqivalent to
GC.collect(GC.maxGeneration). You shouldn't make any
assumptions about when Your finalize() method will start
working, and about the order of execution of finalize()
methods, because the F-Reachable queue is processed by a
separate thread and is completely non-deterministic.
Anyhow, You can use
GC.WaitForPendingFinalizers() method to block the current
thread and wait until the F-Reachable queue is processed.
GC.collect()
GC.WaitForWaitingFinalizers()
GC.collect()
Try to implement IDisposable interface instead of a
Finalize() method when possible.
Look for "GC class" in MSDN.