Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
i am trying to start a thread on button click and call a method in thread and use the return value of method in the main function in MFC.

char* exampleDlg::methodname(char *protType)
{
-------
-------
------
-------
return;
}
C#
void exampleDlg::Onclick()
{

THREADSTRUCT *_param = new THREADSTRUCT;
    _param->_this = this;
    AfxBeginThread (StartThread, _param);




}


UINT exampleDlg::StartThread(LPVOID param)
{
methodname();
return k;
_endthread();
}
Posted

1 solution

You cannot pass instance methods to AfxBeginThread. A workaround is shown here: "Callbacks, Threads, and MFC"[^] (see the the "Worker Threads in a class" section at the bottom of the page).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900