Re: Failed compile when adding AfxBeginThread



Lilith wrote:

I may have brought this up a while back but haven't met with any
success regarding the suggestions I received.  This is frustrating to
the point of needing to post again.

Essentially I'm attempting my first shot at a worker thread.  When the
"go" button is clicked it invokes...

void CUNCTestView::OnUncButton() {
CWinThread *eSafeThread = AfxBeginThread (CUNCTestView::ProcesseSafe, NULL);
}


The header for the thread function is...

UINT CUNCTestView::ProcesseSafe(LPVOID pParam)

The error I get is...

'AfxBeginThread' : none of the 2 overloads can convert parameter 1
from type 'unsigned int (void *)'

I thought that perhaps the problem was the this pointer being passed
to AfxBeginThread so I tried making the function static. That brought
a different complaint from the compiler.


Is it possible that functions passed to AfxBeginThread need to be
non-members of a class?  Should I break off this function from the
class and make it stand alone?

TIA,

Lilith:

The thread function must be a non-class function, or a static member of a class. Show us the error you get when you make the thread function a static member.

David Wilkinson
.


Loading