Passing arguments to a worker thread function
-
Hi everyone:->. I need to pass some arguments to a worker thread function (VC++), but i don't know how to do that ... the MSDN says : UINT MyControllingFunction( LPVOID pParam ), but I need to pass to MyControllingFunction other parameters too. If anyone can help, please do it.:)
-
Hi everyone:->. I need to pass some arguments to a worker thread function (VC++), but i don't know how to do that ... the MSDN says : UINT MyControllingFunction( LPVOID pParam ), but I need to pass to MyControllingFunction other parameters too. If anyone can help, please do it.:)
The LPVOID pParam should be set to point to a structure that contains all of the parameters that you wish to pass. Is this what you need? :) Chris Meech I am Canadian. [heard in a local bar] Gently arching his fishing rod back he moves the tip forward in a gentle arch releasing the line.... kersplunk [Doug Goulden] Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
-
Hi everyone:->. I need to pass some arguments to a worker thread function (VC++), but i don't know how to do that ... the MSDN says : UINT MyControllingFunction( LPVOID pParam ), but I need to pass to MyControllingFunction other parameters too. If anyone can help, please do it.:)
I demonstrate by passing your Class pointer to your
Worker thread
. Let your class beCMyClass
and Worker thread function something like this[vccode]
// Thread function
UINTMyControllingFunction
( LPVOID pParam );// Class
void CMyClass::StartThread();
{
AfxBeginThread(&MyControllingFunction
,(LPVOID)this
);}
// Actual Defination of Worker Thread
UINT MyControllingFunction( LPVOID pParam )
{
CMyClass *pMainClass
=(CMyClass*)pParam
;
//do something with pMainClass.......//end thread
return 0;
}
[Vote One Here, Complete my Survey....] Alok Gupta
visit me at http://www.thisisalok.tk "I Think Believe this Will Help"