Solved

Thread Basics

Posted on 2003-11-11
1
300 Views
Last Modified: 2013-11-20
I'm trying to start a thread in a class I've written using AfxBeginThread

What I want the thread to do is (almost) constantly monitor the status of another executable after I've started it.  The problem is, I can't figure out how to make AfxBeginThread work.

Here's the essence of my call:

void MyClass::StartThread()
{
this->monitorThread = AfxBeginThread(ThreadFunc,NULL,
THREAD_PRIORITY_NORMAL,0,0);
}


Then,
UINT MyClass::ThreadFunc(LPVOID p)
{
   //do stuff
}

I keep getting:
 error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'UINT (LPVOID)'

Any suggestions?  Thanks!

0
Comment
Question by:lakers2003
1 Comment
 
LVL 3

Accepted Solution

by:
freewell earned 125 total points
ID: 9728085
The ThreadFunc needs to be a static or global function.

MyClass
{
    int nData;
    static UINT MyClass::ThreadFunc(LPVOID p);
}

void MyClass::StartThread()
{
    this->monitorThread = AfxBeginThread(ThreadFunc,this,THREAD_PRIORITY_NORMAL,0,0);
}

UINT MyClass::ThreadFunc(LPVOID p)
{
    MyClass* _this = (MyClass*)p;

    //do stuff
    _this->nData = 0;
}
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

760 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

18 Experts available now in Live!

Get 1:1 Help Now