Create several important functions of the thread ..

Source: Internet
Author: User
Cwinthread * afxbeginthread (afx_threadproc pfnthreadproc,
Lpvoid lparam,
Int npriority = thread_priority_normal,
Uint nstacksize = 0,
DWORD dwcreateflags = 0,
Lpsecurity_attributes lpsecurityattrs = NULL
); // Used to create the return value of the worker thread: a pointer to the thread object of the new thread pfnthreadproc: the entry function of the thread. The declaration must be as follows: uint mythreadfunction (lpvoid pparam ), cannot be set to NULL; pparam: The parameter passed into the thread. Note that its type is lpvoid, so we can pass a struct into the thread. npriority: Specifies the thread priority, which is generally set to 0. give it a common priority with the main thread. nstacksize: Specifies the stack size of the newly created thread. if the value is 0, the newly created thread has the stack dwcreateflags of the same size as the main thread: Specifies the mark of the thread after it is created. you can specify two values: create_suincluded: After the thread is created, it will be suspended until the call: resumethread0: starts running after the thread is created. lpsecurityattrs: point to a security_attributes struct, which is used to indicate the security of newly created threads. if it is null,

 

Createthread prototype:

Handle encode (assign parameter, DWORD dwstacksize, assign lpstartaddress, lpvoid lpparameter, DWORD parameter, lpdword lpthreadid); afxendthread (1) void afxapi afxendthread (uint nexitcode, bool bdelete = true ); // function prototype Declaration 1 (2) void afxendthread (uint nexitcode); // function prototype Declaration 2 this method is used to terminate the thread currently being executed, it must be called within the current thread to take effect. Return Value: void

Getexitcodethread bool getexitcodethread (handle hthread, lpdword lpexitcode); on Windows NT/2000/XP, the handle must have the thread_query_information permission. Createevent

Directory

Function Description
Function prototype
Parameters
Return Value
Example
Environment
Edit this function description to create or open a named or unknown event object. Edit this function prototype handle createevent (lpsecurity_attributes lpeventattributes, // Security Attribute bool bmanualreset, // reset bool binitialstate, // the initial state of the lpctstr lpname // Object Name); edit the parameter lpeventattributes: [input] a pointer to the security_attributes structure, determine whether the returned handle can be inherited by the quilt process. If lpeventattributes is null, this handle cannot be inherited. Windows NT/2000: the members in the lpeventattributes structure specify a security token for the new event. If lpeventattributes is null, the event will get a default security token. Bmanualreset: [input] specifies whether to manually restore or automatically restore the event object. If it is true, you must use the resetevent function to manually restore the event state to the stateless state. If this parameter is set to false, when an event is released by a waiting thread, the system automatically restores the event status to the stateless state. Binitialstate: [input] specifies the initial state of the event object. If this parameter is set to true, the initial state is a signal state; otherwise, the initial state is a signal state. Lpname: [input] specifies the name of the event object. It is a string pointer that ends with 0. The character format of the name is limited to max_path. The name is case sensitive. If the name specified by lpname is the same as the name of an existing named event object, the function requests event_all_access to access the existing object. At this time, because the bmanualreset and binitialstate parameters have been set in the event creation process, these two parameters will be ignored. If lpeventattributes is a parameter that is not null, it determines whether the handle can be inherited, but its security descriptor members are ignored. If lpname is null, an unknown event object is created.

 

 

 

 

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.