You need to provide some locking mechanism on the file.
The core of this problem is with the way that XmlDocument works. When you load it, it reads the whole XML file into object memory and releases the file. So another instance of the program can do the same and neither will know about the other. I haven't done this type of work but I imagine there is some way to lock the file using the System.IO.File class. You can load an XmlDocument
from a file stream. So you could manually open the file using the File class methods to obtain a file stream with a lock on the file, then fill your XmlDocument from it, keeping the file open. This will provide the lock at the file system level so another program instance can't write to it until you release it. The other program could be forced to wait to provide read-only access to the file.