Subj : Re: 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 : David Schwartz Date : Mon Aug 29 2005 05:26 pm wrote in message news:1125357370.543175.203810@g43g2000cwa.googlegroups.com... > 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? You should have some structure that represents the calculation and the thread should put the result in that structure. > DWORD WINAPI CalcThreadProc(void * param) > { > ST_CALC* st_calc =(ST_CALC *)(param); Well, you already do that, you have an 'ST_CALC' structure. > while(1){ > if( ::WaitForSingleObject(evShouldStop, 0) == WAIT_OBJECT_0) > break; > > int ret = Calculate(false, st_calc->start, 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? Put the result in a slot in the ST_CALC structure. DS .