I am using c++;
in .h: static CRITICAL_SECTION g_CS;
in .cpp: CRITICAL_SECTION CQCommon::g_CS;
but I want to use
QGUID temp;
EnterCriticalSection(&g_CS);
temp = g_GUID++;
LeaveCriticalSection(&g_CS);
return temp;
in one static function. How can I invoke InitializeCriticalSection(PCRITICAL_SECTION pcs);
Can I using the following one:
QGUID func(XXX)
{
static {
InitializeCriticalSection(&g_CS);
}
QGUID temp;
EnterCriticalSection(&g_CS);
temp = g_GUID++;
LeaveCriticalSection(&g_CS);
return temp;
}
And How can I invoke DeleteCriticalSection(&g_CS) after app leave? Many Thanks for your answers!
Using MFC, it seems CCriticalSection is a solution.