Last post Feb 26, 2012 12:33 AM by Decker Dong - MSFT
Feb 24, 2012 05: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 07: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 06:04 AM|rpk2006|LINK
In that case, I added: connection.dispose in the finally section after the connection got closed?
Feb 25, 2012 10:02 AM|N_EvilScott|LINK
You can do that yeah
Feb 26, 2012 12:33 AM|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。