Hi, how can I detect if a file is locked and wait until it is unlocked? I have a plug-in that begins the process of unlocking but right now it only works if I naively sleep for about a second. (I'm trying to avoid the restart in uninstall.)
In testing, a second is enough time for the lock to release, but 250 ms is too little. However, maybe this will vary depending on the machine. Ideally I would like to wait up to 4-5 seconds but check every 500 ms or so.
Detecting file lock and waiting
-
- Site Admin
- Posts: 5361
- Joined: Sun Aug 22, 2010 4:28 am
Re: Detecting file lock and waiting
Dear Tofutim,
as already said on a different post, the best approach is with checking if the file can be opened.
http://stackoverflow.com/questions/876473/is-there-a-way-to-check-if-a-file-is-in-use
You may execute such verification in a loop in order to verify if the file becomes available.
Hope this helps you.
Regards
as already said on a different post, the best approach is with checking if the file can be opened.
http://stackoverflow.com/questions/876473/is-there-a-way-to-check-if-a-file-is-in-use
You may execute such verification in a loop in order to verify if the file becomes available.
Hope this helps you.
Regards
Francesco Toscano
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Who is online
Users browsing this forum: No registered users and 86 guests