Solved

MFC Threads

Posted on 1998-08-21
1
281 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

695 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