How can we create thread in MFC framework?

Answer Posted / bijender singh

MFC support two type of thread : Worker Thread & UI thread.
There is an overloaded function called AfxBeginThread()for
creating threads in MFC but at APT level you can't
differentaite.
At implementation level you can find the difference:-

For worker thread:
AfxBeginThread(); It takes 6 parameters, first param as
address of thread controlling function(must),2nd as
parameter passed to threadfn(must),3'rd thread priority
level(optional), 4'th as stack size(Optional),5'th as
create_flag(optional),6'th security class(optional)etc.

For UI(User Interface) thread:
Derive a class from CWinThread;
class CMyThread:public CWinThread
{
.....
.....
.....
}
Override the InitInstance() function in this class.

Then use the function
AfxBeginThread()and pass the parameter in RUNTIME_CLASS
macro in this func.
i.e. AfxBeginThread(RUNTIME_CLASS(CMyThread));
It takes 5 parameters ...rest of last four params are same
as worker thread which are optional.

So in this you can create the Worker and User Interface
threads.

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I want recent paper pattern for HP company?

2038


what message is sent to an application when the user presses the primary button?

1609


plzz tell me what we can do and dont in tally ERP & sap business one?

2092


What is mfc class hierarchy?

815


Do you have an idea about MFC?

1200


How to handle dynamic menus in mfc? What happens when client calls cocreateinstance?

941


What does mfc stand for?

1212


2.create for 10 batch: Employee_Number Employee_name Employee_Dateofjoining Employee_address Employee_salary 1.select the employee name who deriving more than 10 thousand salary and joined before august 08. use structure and pointers

2020


List out the basic features of MFC.

14431


what is functioning of DIalodDataXchange ..?

1384


what is the meaning of constant FILE EXCEEDS LENGTH LIMIT while loading from ps file to vsam in the jcl?

3582


How do I create a dialog box in mfc?

799


What is the difference between Struts and JSF? Pls list some most suitable differences.

3036


how to repaint when working with horizontal scroll bar

1731