I'm writing a C# program that monitors a dedicated Gmail account using POP3 for specialized command emails and reacts appropriately.
For maximum reliability, I will run this program on several computers throughout the country. I currently have a race condition where two instances of the program can read the same message before one of them deletes it, causing the message to be processed twice.
How can I make sure that each command is processed exactly once?
Gmail's POP3 access used to only serve each message once (making RETR and DELE a single atomic operation), but I can no longer reproduce this behavior.
The only method of communication between the computers is a SQL Server and an HTTP server (which I control).