I need to create two threads in a dll project, one main and one menu. The main thread need to suspend and wakeup menu thread under certain conditions. The method I listed here does not work. I assume it is because the lack of authority in these thread handles. So the question is how to create thread handle with suspend/resume authority?
BOOL WINAPI DllMain(HINSTANCE hModule,DWORD dw_reason,LPVOID lpReserved)
{
switch (dw_reason)
{
case DLL_PROCESS_ATTACH:
MainHandle=CreateThread(0, 0, MainThread, hModule, 0, &MainThreadID);
MenuHandle=CreateThread(0, 0, MenuThread, hModule, CREATE_SUSPENDED, &MenuThreadID);
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
DWORD WINAPI MenuThread(LPVOID param) {
........; UI Updating Code Here
return 0;
}
DWORD WINAPI MainThread(LPVOID param) {
......; Main Logic Code Here
if (KeyPressed) {
ResumeThread(MenuThread);
}else{
SuspendThread(MenuThread);
}
return 0;
}