void RazerMonitorThread::Execute(void * data) { bool rereg = true; while(!isTerminated()) { if(rereg) { LONG lError = RegNotifyChangeKeyValue(hMonitoredKey, true, REG_NOTIFY_CHANGE_LAST_SET, hKeyEvent, true); if(lError != ERROR_SUCCESS) { ErrorMsg("RegNotifyChangeKeyValue"); setTerminated(true); } rereg = false; } DWORD ret = WaitForSingleObject(hKeyEvent, 1000); if(ret != WAIT_FAILED && ret != WAIT_TIMEOUT) { for(int i = 0; i < NUM_MONITORED_KEYS; i++) keyChangeCallbacks[i](); rereg = true; } else if(ret == WAIT_TIMEOUT) { addAPM(); } } if(hKeyEvent != NULL) CloseHandle(hKeyEvent); if(hMonitoredKey != NULL) RegCloseKey(hMonitoredKey); }
void RazerMonitorThread::Setup() { LONG lError; lError = RegOpenKeyEx(hMainKey, monitoredKey, 0, KEY_READ | KEY_NOTIFY, &hMonitoredKey); if(lError != ERROR_SUCCESS) { ErrorMsg("RegOpenKey"); setTerminated(true); return; } hKeyEvent = CreateEvent(NULL, false, false, "APMAlert2RegMonitor"); if(hKeyEvent == NULL) { ErrorMsg("CreateEvent"); setTerminated(true); } logInfo("Registry monitor thread setup completed."); }
bool JingleSession::terminate(IJingle::Reason AReason) { JingleStanza stanza(FThisParty, FOtherParty, FSid, IJingle::SessionTerminate); FActionId=stanza.id(); FAction=IJingle::SessionTerminate; stanza.setReason(AReason); if (FJingle->sendStanzaOut(stanza)) { setTerminated(AReason); return true; } return false; }
void MovingItem::tickEffect(void) { if(!MPoint::equals(&endPoint)) { setPoint(x + speed, y + speed); if(x > endPoint.getX()) { x = endPoint.getX(); } if(y > endPoint.getY()) { y = endPoint.getY(); } } else { setTerminated(true); } }
void IsapiServer::serverEntry() { HMODULE module = GetCurrentModule(); char DllPath[_MAX_PATH]; char *pDllPath = DllPath; GetModuleFileName(module, DllPath, _MAX_PATH); FreeLibrary(module); try { main(1, &pDllPath); terminationMsg = mainReturnedReply; if (hasConfiguration()) log("fatal") << "ISAPI: main() returned"; } catch (std::exception &e) { terminationMsg = uncaughtExceptionReply; if (hasConfiguration()) log("fatal") << "ISAPI: uncaught main() exception: " << e.what(); } catch(...) { terminationMsg = uncaughtExceptionReply; if (hasConfiguration()) log("fatal") << "ISAPI: unknown uncaught main() exception"; } setTerminated(); }
void TPZComponent :: terminate() { // Initialization is not required at this point. setTerminated(true); }