Solved

MFC Threads

Posted on 1998-08-21
1
237 Views
Last Modified: 2013-11-20
I am writing a pogram the uses threads.
I would like that the thread function will be one of the class's member functions.
for example:

void CMyClass::CallThread()
{
    AfxBeginThread(TheadFunc, NULL);
}

UINT CMyClass::TheadFunc( LPVOID p )
{
  ......
}

When I do this I recieve the following error:
none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'

!! What am I doing wrong??!?!?!?! I feel this is so simple!
Please help - I am desprate!!!
0
Comment
Question by:xmichaelm
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
Comment Utility
A member function has a implicit parameter, which is the this pointer. The function prototype is actually
UINT CMyClass::TheadFunc(CMyClass *pThis, LPVOID p);

It does not match what AfxBeginThread requires.

Define it as a static member function. If you want to access the member variables, you can pass them by the memory pointed to by LPVOID.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now