Can the writer notify you of the completed task through the same channel that your "application sends a message to a third party program" through?
If you are spawning the third-party program as a process that terminates when finished then wait on that event before opening the file. If that program can output to standard output then you can do the whole thing through QProcess.
If you have control of the writer application you can have the writer create two files, file.dat and file.dat.lock, and delete the lock file when finished writing the main file. When the lock file disappears the file is ready. Of course, if you have control of the writer a shared memory segment would be another option.
If you do not have control of the writer you could attempt to open the file for read/write access. If the open fails then back off for a few seconds and try again. Each time it fails wait a little longer (up to some maximum). When the open succeeds the writer's lock on the file has been released. Busy polling is not pretty but if the average processing time is fairly well known then you can tune it it rarely need to retry.
Bookmarks