Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHi Help me write this program (tuan1111) Pin
tuan11111-Jun-09 17:37
tuan11111-Jun-09 17:37 
QuestionCreating Threads using Class Object functions Pin
jobin0070071-Jun-09 15:38
jobin0070071-Jun-09 15:38 
AnswerRe: Creating Threads using Class Object functions Pin
David Crow1-Jun-09 17:04
David Crow1-Jun-09 17:04 
GeneralRe: Creating Threads using Class Object functions Pin
jobin0070071-Jun-09 17:30
jobin0070071-Jun-09 17:30 
GeneralRe: Creating Threads using Class Object functions Pin
David Crow2-Jun-09 2:30
David Crow2-Jun-09 2:30 
GeneralRe: Creating Threads using Class Object functions Pin
norish2-Jun-09 2:09
norish2-Jun-09 2:09 
NewsRe: Creating Threads using Class Object functions Pin
norish2-Jun-09 2:12
norish2-Jun-09 2:12 
AnswerRe: Creating Threads using Class Object functions Pin
Stuart Dootson2-Jun-09 2:25
professionalStuart Dootson2-Jun-09 2:25 
jobin007007 wrote:
unfortunately Visual C++ 2008 has some issues with Boost::threads package


Really? Like what, pray tell? I've used VS2008 with Boost.Threads and I'd like to know what issues I might encounter...

Here's how I've implemented the pattern you want in the past:

class Updater
{
public:
  static Updater* StartUpdate()
  {
    Updater* u = new Updater();
    HANDLE hThread = (HANDLE)_beginthread(Updater::ThreadProc, 0, (LPVOID)u);
    return u;
  }

  static void ThreadProc(void* lpvUpdater)
  {
    Updater* updater = (Updater*)lpvUpdater;
    updater->DoUpdate();
  }
  void DoUpdate()
  {
    // Do the update
  }
};


The thread function is Updater::ThreadProc. This is passed an Updater instance pointer, which it uses to call the member function you actually want to call.

Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

GeneralRe: Creating Threads using Class Object functions Pin
jobin0070072-Jun-09 4:27
jobin0070072-Jun-09 4:27 
GeneralRe: Creating Threads using Class Object functions Pin
Stuart Dootson2-Jun-09 5:13
professionalStuart Dootson2-Jun-09 5:13 
GeneralRe: Creating Threads using Class Object functions Pin
jobin0070072-Jun-09 12:17
jobin0070072-Jun-09 12:17 
GeneralRe: Creating Threads using Class Object functions Pin
Stuart Dootson2-Jun-09 12:30
professionalStuart Dootson2-Jun-09 12:30 
GeneralRe: Creating Threads using Class Object functions Pin
jobin0070072-Jun-09 4:33
jobin0070072-Jun-09 4:33 
GeneralRe: Creating Threads using Class Object functions Pin
Stuart Dootson2-Jun-09 5:25
professionalStuart Dootson2-Jun-09 5:25 
QuestionIs it "ok" to get array length this way Pin
FocusedWolf1-Jun-09 12:46
FocusedWolf1-Jun-09 12:46 
GeneralRe: Is it "ok" to get array length this way Pin
norish1-Jun-09 13:27
norish1-Jun-09 13:27 
GeneralRe: Is it "ok" to get array length this way Pin
FocusedWolf1-Jun-09 16:07
FocusedWolf1-Jun-09 16:07 
AnswerRe: Is it "ok" to get array length this way Pin
Stuart Dootson1-Jun-09 14:43
professionalStuart Dootson1-Jun-09 14:43 
GeneralRe: Is it "ok" to get array length this way Pin
Chris Losinger1-Jun-09 15:35
professionalChris Losinger1-Jun-09 15:35 
GeneralRe: Is it "ok" to get array length this way Pin
FocusedWolf1-Jun-09 16:15
FocusedWolf1-Jun-09 16:15 
GeneralRe: Is it "ok" to get array length this way Pin
Stuart Dootson1-Jun-09 20:27
professionalStuart Dootson1-Jun-09 20:27 
GeneralRe: Is it "ok" to get array length this way Pin
FocusedWolf2-Jun-09 4:27
FocusedWolf2-Jun-09 4:27 
GeneralRe: Is it "ok" to get array length this way Pin
Stuart Dootson1-Jun-09 20:32
professionalStuart Dootson1-Jun-09 20:32 
QuestionRe: Is it "ok" to get array length this way Pin
David Crow1-Jun-09 17:08
David Crow1-Jun-09 17:08 
AnswerRe: Is it "ok" to get array length this way Pin
FocusedWolf2-Jun-09 4:26
FocusedWolf2-Jun-09 4:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.