Hi,
Is there a way in C# compact framework to ensure closing for instance database connection before exiting program? In Java this is handled by using shutdown hooks.
Regards,
Mikko
Shutdown hook in C# (compact framework 2.0)
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Scott LysleRank #49 · 31K reputationPosted Dec 28, 2007, 12:10 PM EST
If your connection has class wide scope you could release it in the form dispose method; however, if you were to declare your connections within the scope of some method, you can use the using statement which will release the collection when it goes out of scope (example):
using
(SqlConnection conn = new SqlConnection(Properties.Settings.Default.ConnectionString)){
Mikko4 reputationPosted Jan 6, 2008, 9:38 PM EST