the operating system has several status changes to the thread: Execution, suspension, and recovery.
when the thread finishes the task or wants to pause the running of the thread, you need to use suspendthread to pause the thread execution. Of course, to resume the thread execution, you need to use the resumethread function. These two functions are easy to use. Let's take a look at how the examples are used.
the suspendthread and resumethread functions are declared as follows:
winbaseapi
DWORD
winapi
suspendthread (
_ in handle hthread
);
winbaseapi
DWORD
winapi
resumethread (
_ in handle hthread
);
hthread is the thread handle.
An example of calling a function is as follows:
#001 // thread suspension and restoration.
#002 // Cai junsheng 2007/10/15 QQ: 9073204 Shenzhen
#003 void threadsuspendresume (void)
#004 {
#005 :: suspendthread (m_hthread);
#006
#007 sleep (10);
#008: resumethread (m_hthread );
#009 }< BR >#010
row 5th is used to suspend thread execution.
Row 3 is to continue thread execution
this article from the csdn blog, reprinted please indicate the source: http://blog.csdn.net/caimouse/archive/2007/10/15/1826404.aspx