One-day training of Windows APIs (50) suspendthread and resumethread Functions

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.