Solved

MFC Threads

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 84
Named range not carried over 10 61
method notes when mouse over in eclipse 5 82
firstChar challenge 13 106
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

11 Experts available now in Live!

Get 1:1 Help Now