Creating a thread problem/error
I want to create a thread in my program (implementation is irrelevant). I get the following compile error with VC6:
"error C2665: ''AfxBeginThread'' : none of the 2 overloads can convert parameter 1 from type ''unsigned int (void *)"
Afaik im prototyping the thread function correctly, and including the neccessary headers. All relevant files are included in the procject etc.
Anyone have any ideas? :-)
Here''s a quick snippet of the code, with the irrelevant stuff ommited.
// Thread function
UINT MyThread( LPVOID pInData )
{
// ... whatever
return 0;
}
then where i create the thread
#include <afxwin.h>
#include <afxres.h>
// ...
extern UINT MyThread( LPVOID pInData );
void SomeFunction( void )
{
AfxBeginThread( MyThread, NULL );
}
I''m not sure, but my reference shows that the thread procedure is a class method, not a vanilla function. Try putting MyThread into a class. Not sure if that is the problem, though...
define your thread procedure as so.
DWORD WINAPI MyThread(LPVOID pInData)
{
DWORD dwResult;
return (dwResult);
}
PLEASE, read the MSDN if you are going use Win32 functions. it saves YOU a lot of trouble.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
Edited by - jenova on January 29, 2002 10:34:57 PM
DWORD WINAPI MyThread(LPVOID pInData)
{
DWORD dwResult;
return (dwResult);
}
PLEASE, read the MSDN if you are going use Win32 functions. it saves YOU a lot of trouble.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
Edited by - jenova on January 29, 2002 10:34:57 PM
> PLEASE, read the MSDN if you are going use Win32 functions. it saves YOU a lot of trouble
I did read MSDN, and it told me to define my thread function exactly as _I_ did, not as you have.
Regardless, I found the problem; it was quite simple actually. AfxBeginThread is member function in a class derived from CMainWin (iirc). I was calling it from a different class - i just moved the creation of the thread into that class where it should be and it was all cool.
Oldguy was along the right track :-)
thanks!
Edited by - a_question on January 29, 2002 11:32:17 PM
I did read MSDN, and it told me to define my thread function exactly as _I_ did, not as you have.
Regardless, I found the problem; it was quite simple actually. AfxBeginThread is member function in a class derived from CMainWin (iirc). I was calling it from a different class - i just moved the creation of the thread into that class where it should be and it was all cool.
Oldguy was along the right track :-)
thanks!
Edited by - a_question on January 29, 2002 11:32:17 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement