Solved

MFC Threads

Posted on 1998-08-21
1
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 1321123
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 155
Process filename extension 3 218
ASCII Non-Printable characters/codes and their HTML equivalents 6 159
EvenOdd challenge 10 160
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Suggested Courses

732 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