开发者

Polling directory on File Server

开发者 https://www.devze.com 2023-03-13 01:23 出处:网络
I need to write an application that polls a directory which contains images on a file server and display 4 at a time.

I need to write an application that polls a directory which contains images on a file server and display 4 at a time.

This application will be run up to 50 times across the network at the same time.

I'm trying to think of the best architect开发者_C百科ure to complete this requirement.

I was working on the idea of opening a file with read/write access and no file share allowed so that if another PC came in to read it it would error and it would have to move on to the next one, the problem is, is that I need to access all 4 images in sequence on the same pc ensuring other pc's dont try to open them. So for example if PC1 tries to open 1.jpg it needs to be able to open 1,2,3,4.jpg. If another PC comes in at the same time to read them I need a way for it to then open 5,6,7,8.jpg and so on and so on.

It seems a simple requirement but a nightmare to try and build successfully.


You're basically dealing with a race condition here, and I don't see a way to handle it from separate instances of your application running on separate machines unless you can guarantee your file naming will always follow a standard naming convention that would allow you to work with the sequence of 4 files using only the name of the first.

The best way to handle this would be using a centralized resource to manage access to your files, either a database as was suggested in a comment or else a service (such as WCF) that would "hand out" each set of 4 files.


What about creating a 1.jpg.lock file? The presence of a the file indicates the images are locked and any other instance of the application should skip that set.

0

精彩评论

暂无评论...
验证码 换一张
取 消