I am running a service that queries on regular intervals. I initially set it up so that the connection formed onStart, and closed onStop. This of course leaves a connection open all the time, which isn't what I want. So I moved the open and closed to inside my timer event handler.
My question: Is there a difference between
try{connection.Open();}
catch{error;}
someAction();
try{connection.Close();}
catch(Exception)
{error}
and
try{ connection.Open();
someAction();
connection.Close();
}
catch(Exception)
{error}
If so which is better?