_beginthread and MFC
-
Hello I need to access a member-function of my MFC-app via the _beginthread-function. _beginthread(pingthread,0,(void *) (szBuffer)); "pingthread" is void CMyAppDlg::pingthread(void* parameter) { ... } But _beginthread does not seem to accept MFC-member-functions. Any solution? thanks
-
Hello I need to access a member-function of my MFC-app via the _beginthread-function. _beginthread(pingthread,0,(void *) (szBuffer)); "pingthread" is void CMyAppDlg::pingthread(void* parameter) { ... } But _beginthread does not seem to accept MFC-member-functions. Any solution? thanks
-
Hello I need to access a member-function of my MFC-app via the _beginthread-function. _beginthread(pingthread,0,(void *) (szBuffer)); "pingthread" is void CMyAppDlg::pingthread(void* parameter) { ... } But _beginthread does not seem to accept MFC-member-functions. Any solution? thanks
I would suggest you to read one of newcomer's articales: http://www.pgh.net/~newcomer/callbacks.htm ;) Lirong
-
Hello I need to access a member-function of my MFC-app via the _beginthread-function. _beginthread(pingthread,0,(void *) (szBuffer)); "pingthread" is void CMyAppDlg::pingthread(void* parameter) { ... } But _beginthread does not seem to accept MFC-member-functions. Any solution? thanks
I'd do the following: 1) Create a global function : void ThePingThread(void * pDlg) { if (pDlg != NULL) { ( (CMyAppDlg *) pDlg)->PingThread() ); } } 2) ...calling the pingthread function in your thread void CMyAppDlg::pingthread() { pParameter = m_pParamter; // Do your pinging stuff! } 3) Start the trhead as follows: void CMyAppDlg::RunPingThread(void* pParameter) { m_pParameter = pParameter; _beginthread(ThePingThread, 0, this); } It works for me! Structured programming vs. chaotic mind boggling
-
I'd do the following: 1) Create a global function : void ThePingThread(void * pDlg) { if (pDlg != NULL) { ( (CMyAppDlg *) pDlg)->PingThread() ); } } 2) ...calling the pingthread function in your thread void CMyAppDlg::pingthread() { pParameter = m_pParamter; // Do your pinging stuff! } 3) Start the trhead as follows: void CMyAppDlg::RunPingThread(void* pParameter) { m_pParameter = pParameter; _beginthread(ThePingThread, 0, this); } It works for me! Structured programming vs. chaotic mind boggling
-
When I try to compile the compiler reports an error in line: ( ((CServerListDlg*) pDlg )->pingthread() ); (translated from german :)) "pingthread" : No access to protected element, which has been declared in class "CServerListDlg"
That's quite logical, because you have to make the pingThread function public. If it's protected, it's quite impossible for a global function to access it... Tell me if it worked for you! Structured programming vs. chaotic mind boggling