I’ve two threads, one that writes to a file, and one that reads from the same file.
I use CreateFile & WriteFile, FlushFileBuffers in the writer thread, and the reader thread uses FtpPutFile.
How do I implement a simple windows32 Mutex here? (I haven’t used it for years)
Or, is this possible with proper flags sent to CreateFile? (I tried but no luck)
How to implement a simple mutex:
You create a mutex with the CreateMutex function OR CreateMutexEx. You will need to call CloseHandle when you are done with it. Once you have the mutex then you can call WaitForSingleObject to synchronize your calls (don’t forget to call ReleaseMutex when you are done. Lastly, here is an example of using the Mutex object.