I have seen several similar issues on Stack before but nothing that seems to fit my needs.
I have a simple scenario. A webpage that streams a pdf file but a separate service that updates that same pdf file every so often. I have written both the web site and the serive so I can do whatever needs to be done.
The service actually does everything it needs to to do to a temp file and then at the very end it replaces or moves the temp file to the final pdf location.
My thought was to use a named mutex but the service generates a lot of pdf files so I don't want all pdf files locked from reading because I am writing a specific pdf at the moment. I didn't think it was practical to have a named mutex for every single pdf file either.
This seems like it should be simple. What am I missing? Suggestions on how to control access to each pdf file so the webpage does not try to stream it at the same moment the service tries to overwrite it? Logs show this happens several times every day.