I have an executable which is hosted on a server and can be launched from several client work stations. The exe needs to read and write to two text files that are located in a location shared between all the clients. I need to lock the first text file, and if a lock is obtained successfully the second file needs to be locked for writing and do some processing and unlock the files after processing. So at any time, only one user should be able to access the files.
Also, I need to display some message to the user to try again when the files are locked by another user. It should keep checking if the files are unlocked and keep asking to try again.
Once the files are unlocked, it should show some message to say the files are unlocked and should be automatically available for the next user to lock and do the processing and unlock after processing.
Did Anybody come across this situation and implemented any of this?
If you could show me some code that would be very helpful. Thank you.