You need to use the thread handle that was returned when you created the thread. See documentation for CreateThread
; SuspendThread
; and ResumeThread
.
In particular, from the documentation for CreateThread
:
If the function succeeds, the return value is a handle to the new thread. If the function fails, the return value is NULL.
Example:
HANDLE thread_handle = CreateThread(/*args*/); // hold on to this value (and check for failure)
if (thread_handle == NULL)
{
// handle creation error
}
DWORD suspend_retval = SuspendThread(thread_handle);
if (suspend_retval == static_cast<DWORD>(-1))
{
// handle suspend error
}
Scr_AddInt(1); // original work
DWORD resume_retval = ResumeThread(thread_handle);
if (resume_retval == static_cast<DWORD>(-1))
{
// handle resume error
}
It may be worthwhile to create a wrapper class that encapsulates thread creation, suspension, resumption, and termination. This class can perform all error checking internally, and throw an exception when appropriate.