A file is opened by a thread for writing. The reference to the file is a local variable in a method and therefore unable to be cleaned up by dispose or a finalizer.
The code uses a using statement to make sure that the file is closed and all locks are released during normal operation. However, in the instance of a site be shut down, the using statement might not get a chance to clean up the FileStream. However, the IIS process may stay open, so the lock will not be released unless the server is restarted.
What is the best way to prevent a file lock from hanging if the site is stopped or restarted?
Or does the way IIS shut down a site mitigate this concern?