Concurrent file access reading/writing
Can someone point me in the right direction? Dim fs As New IO. Open, IO. ReadWrite fs. The content you requested has been removed. Ask a question. I'd also be a bit concerned that if you're locking by user it would be possible for a user to run two instances of the application I do this all the time with explorer and perform two interacting changes without realising it as both instances believe they hold the lock.
This is often overcome by storing an additional piece of information, such as the processId that holds the lock. I'm adding this as a separate answer, because I feel a bit like I'm missing something, which you may well be managing in another class that you haven't posted and this is too big for a comment. Looking at the problem you've said you want to avoid this situation:. User B initiates the long running process coping files from FolderB to Sub2. To do that, they either lock Root or more specifically they try to lock FolderA.
For the lock to be valid, none of the subfolders can have a lock on them? The code that checks this doesn't appear to be in the code you've posted. Assuming I'm correct about the expected behaviour, and that the code does exist somewhere else, it would raise a concern about the way AddEntry works.
AddEntry essentially does this processing:. As there are no checks at this lower level for the nested directory lock then if for any reason the higher level decision making gets out of sync it may attempt to gain a lock that it shouldn't. Surely the path is the important bit of the check.
The time aspect in particular seems like it will result in the match never being made. Maybe you're handling all of this in the higher level code and filtering log entries based on the time they were created to decide if the application holds a lock or not, however it then relies on all your clocks being in sync which can be an issue. After applying the suggestion from Nikita B and forsvarir, the class LockStorage could be refactored to the following:.
Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?
Learn more. Asked 5 years, 6 months ago. Active 5 years, 6 months ago. Viewed 10k times. Problem The parallel access to the file system may result in conflicts. Requirements An application should be able to lock folders if required. Other applications should be notified as soon as possible about locks, so that these applications may disable corresponding commands e.
Rename will be disabled for a folder where any child folder is locked. All kinds of network shares should be supported windwos, samba, Approach To avoid conflicts as described above, a centralized locking mechanism should be introduced. Ensure "path".
IsNotNull ; user. Ensure "user". Split ' ' ; if entryParts. IsNullOrWhiteSpace path string. IsNullOrWhiteSpace user! InvariantCulture, DateTimeStyles. ToString CultureInfo. Equals other. SetLength writeStream. Open FileMode. OpenOrCreate, FileAccess. ReadWrite, FileShare. None ; fileInfo. WriteLine entry. Hi, What are the differences between concurrent and enhanced concurrent VGs.? For that i have to do some pre-requsite ie. Shell Programming and Scripting. Concurrent execution.
The thing is that it takes too long to insert them all one by one, so I want to insert them five at a time. We have a very large text file.. We want to process this file to generate another text file as per our data requirement. As for now the parsing of data takes mins each , for K lines. IP Networking. Just like concurrent tcp server, anyone know how to design the concurrent udp server with the thread? Concurrent writing to file. We can't always guarantee that the perfect solution to your specific problem will be waiting for you.
If you ask your own question - our Certified Experts will team up with you to help you get the answers you need. Who are the certified experts? How quickly will I get my solution? We can't guarantee quick solutions - Experts Exchange isn't a help desk. We're a community of IT professionals committed to sharing knowledge. Our experts volunteer their time to help other people in the technology industry learn and succeed.
Plans and Pricing.
0コメント