Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Thread Basics

Posted on 2003-11-11
1
Medium Priority
?
312 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
[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 3

Accepted Solution

by:
freewell earned 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

715 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