Archived

This topic is now archived and is closed to further replies.

a_question

Creating a thread problem/error

Recommended Posts

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 ); }

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
> 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

Share this post


Link to post
Share on other sites