I thought that WaitForSingleObject would return immediately for a thread which is stoped, but in the code below the WaitForSingleObject seems to wait infinitely. Why ?
Code:
volatile bool stop;

DWORD WINAPI SampleThread(LPVOID iValue)
{
	while(!stop) {
		Sleep(500);
	}
	return 0;
}


int WINAPI WinMain(	HINSTANCE hInstance,
					HINSTANCE hPrevInstance,
					LPTSTR    lpCmdLine,
					int       nCmdShow)
{
	stop=false;
	HANDLE hThread;
	DWORD dwGenericThread;
	hThread = CreateThread(NULL,0,SampleThread,NULL,0,&dwGenericThread);
	if(hThread == NULL)
	{
		DWORD dwError = GetLastError();
		return;
	}
	stop=true;
	WaitForSingleObject(hThread,INFINITE);
	return;
}