Subj : Return value from worker thred when the working thread must be suspend after calculation??? To : comp.os.ms-windows.programmer.win32,microsoft.public.vc.language,comp.programming.threads From : pattreeya Date : Mon Aug 29 2005 05:16 pm Hello, it will be a very kind of you if someone can help me with the following problem. After finish calling "Calculate" function, I would like to send the result to the main thread and suspend the working thread. how can i get the the return value from this threadproc to be used by the main thread? My idea for the code goes like this: struct ST_CALC{ int start; int end; } int Calculate(bool flag,int start, int end) { int ret_value = 0; if( ! flag ){ for(int i=start; istart, st_calc->end); ::SuspendThread(hRtCalcThrd); //??? How can I get return value, "ret", to be use by the calling thread? Should I call put the SuspendThread outside this func after get the return value? } //???? ::ExitThread(0); } int MyCalculate(int start, int end) { result = Calculate(true, start, end); if(result){ ::ResumeThread(hRtCalcThrd); } //??? I would like to use the return value from threadproc inside this function, how can we get its return value?? return result; } void Start(int start, int end) { ST_CALC* p; p->start = start; p->end = end; hRtCalcThrd = ::CreateThread(0, 0, CalcThreadProc, p, CREATE_SUSPENDED, m_idThread); result = MyCalculate(); } .