Synchronization in shared memory

  .net-core, c++, shared-memory, synchronization

I have a c++ application that keeps updating a specific block of shared memory. And I have another dotnet core application that reads from that block whenever it needs the data. Currently I am using a flag for synchronization, whenever c++ application starts updating, it sets the flag as true and sets to false after it’s done. Dotnet core application checks whether the flag is false or not before reading. But I think there is some issue in this method.
Is there some other way of doing this?

Source: Windows Questions C++