Beispiel #1
0
unsigned runThread()
{
	if (hThread)
 		ahkTerminate(0);
	hThread = (HANDLE)_beginthreadex( NULL, 0, &runScript, &nameHinstanceP, 0, 0 );
	//hThread = (HANDLE)CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&runScript,&nameHinstanceP,0,(LPDWORD)&threadID);
	//hThread = AfxBeginThread(&runScript,&nameHinstanceP,THREAD_PRIORITY_NORMAL,0,0,NULL);
	WaitIsReadyToExecute();
	return (unsigned int)hThread;
}
Beispiel #2
0
unsigned runThread()
{
	if (hThread && g_script.mIsReadyToExecute)
	{	// Small check to be done to make sure we do not start a new thread before the old is closed
		int lpExitCode = 0;
		GetExitCodeThread(hThread,(LPDWORD)&lpExitCode);
		if ((lpExitCode == 0 || lpExitCode == 259) && g_script.mIsReadyToExecute)
			Sleep(50); // make sure the script is not about to be terminated, because this might lead to problems
		if (hThread && g_script.mIsReadyToExecute)
 			ahkTerminate(0);
	}
	hThread = (HANDLE)_beginthreadex( NULL, 0, &runScript, &nameHinstanceP, 0, 0 );
	WaitIsReadyToExecute();
	return (unsigned int)hThread;
}