Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 25, 2012 11:33 PM by Decker Dong - MSFT
Feb 24, 2012 04:11 PM|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|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|LINK
In that case, I added: connection.dispose in the finally section after the connection got closed?
Feb 25, 2012 09:02 AM|LINK
You can do that yeah
Feb 25, 2012 11:33 PM|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。