Code:
ResumeThread(hThread);
Sleep(8000);
This is bad design, use WaitForSingleObject.
Thread Context Hijacking is unsafe, you should use "ready-to-use-and-working-due-to-years-of-research-and-testing" libraries for this purpose (e.g.
http://www.madshi.net ).