Is it good practice to close and dispose of resources before displaying error messages?
If you are catching errors and you display an error message in the same scope as resources such as database and file objects, then shouldn't these resources be closed and disposed of before the error message is displayed?
If you are waiting for these resources to drop out of scope then they will only do this once the error message dialog is closed. This means that a user could leave the error message on the screen for some time and in doing so keep a lock on some resources.
eg.
try { ... }
catch (Exception e) {
// should close/dispose resources here
...
...
MessageBox("Error");
}