Last post Feb 25, 2012 11:33 PM by Decker Dong - MSFT
Feb 24, 2012 04:11 PM|rpk2006|LINK
I want to clear any old connection objects left in user's PC as soon as the Home Page of my application starts. Is it safe to run
GC.Collect() as application loads?
Feb 24, 2012 06:22 PM|N_EvilScott|LINK
It won't hurt anything no, but the garbage collector won't release those objects unless they are properly disposed of first. If they are still in use the collector will pass over them as being active and in use.
Feb 25, 2012 05:04 AM|rpk2006|LINK
In that case, I added: connection.dispose in the finally section after the connection got closed?
Feb 25, 2012 09:02 AM|N_EvilScott|LINK
You can do that yeah
Feb 25, 2012 11:33 PM|Decker Dong - MSFT|LINK
In fact you can also try to use "using……" statement to a class instance that has implemented the interface of "IDisposible"，which will release the inner unmanaged things together。