|
-
March 25th, 2010, 05:42 AM
#1
Locking a file
Hello everyone,
Two applications share the same file. They execute Read/Write access on this file.
What I need is if an application is reading/writing this file, I want the next application to wait until the first application finishes processing the file.
Is there any way to do this ? I need to use something similar to Mutex/Semaphore to be applied on application scope.
Thank you in advance for your consideration.
-
March 25th, 2010, 05:48 AM
#2
Re: Locking a file
You can keep trying to lock the file in some loop, you can create a FileSystemWatcher on it, or you can use mutex, which can be shared among applications.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post. 
-
March 25th, 2010, 06:27 AM
#3
Re: Locking a file
Thank you for your reply.
I'm running a windows service that detects the existence of an xml file in a directory, if the xml file is there I save the data in the memory, delete the xml file and print the data.
The xml file is generated each now and then by http web requests, so the xml fiile is modified each now and then.
So the Mutex will only be created in Windows Service application ? Can u provide more hints about how to implement on application scope ? I think in my case it would be better if I use Mutex and not System File Watcher as long as my xml file is constantly modified. What do u think?
Thanks again boudino for sharing your knowledge.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|