c# - Preventing open file locks when site is shut down -


a file opened thread writing. reference file local variable in method , therefore unable cleaned dispose or finalizer.

the code uses using statement make sure file closed , locks released during normal operation. however, in instance of site shut down, using statement might not chance clean filestream. however, iis process may stay open, lock not released unless server restarted.

what best way prevent file lock hanging if site stopped or restarted?

or way iis shut down site mitigate concern?

it principle minimise resource locks as possible, , seeing 1 consequence of not doing this. suggest open , lock file when need write it, , release lock , close file afterwards. if worried performance overhead of repeatedly opening file (and seeking end append), should profile code see if performance acceptable.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -