You dont provide much information - like how you declare your variables or how you modify them. I assume you have written it properly as in MSDN documentation:
https://msdn.microsoft.com/en-us/library/h90dkhs0%28v=vs.90%29.aspx?f=255&MSPPError=-2147217396
From your description - that variables are synchronized only after application restart, I can only suspect you have some caching problems. I suggest you make your variables volatile and use atomics to modify/read them.
for example:
#pragma data_seg("Shared")
volatile LONG g_mydata = 0;
#pragma data_seg()
#pragma comment(linker, "/Section:Shared,RWS")
now to modify g_mydata (increment by 1):
InterlockedExchangeAdd((PLONG)&g_mydata, 1);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…