If the Windows application is finished working with the file, it should be closed immediately, because presumably they have closed their file descriptors. There is no delay in unlocking the file while closing the file.
If the program forgets to close its file descriptors, but ends, Windows will release them for them (just not right away). Usually it is not long, but it can be any amount of time, I have not seen it take more than two seconds. But proper cleaning must be done to avoid blocking it.
It is also worth noting that not all programs open files in a locked way. They can open a file that determines the type of access that they would like to grant to other processes, and they can also block parts of the file. They can open a file with full read and write permissions to other processes.
If you do not have control over a process that does not close its file descriptors, but you need to execute it, you can write some loop to continue working on the file for several seconds.
source share