Solved

MFC Threads

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

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 130
Host to IP 7 78
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 431
not able to insert into temp table 68 162
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 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