AslFunky wrote: Is it necessary to do my stuff in a worker thread? That depends on what you need to do. If the process takes a lot of time, you don't want to block the user interface while the process runs. That sort of thing is something you can put in a worker thread. AslFunky wrote: I mean, how will this function UINT threadproc(void* para) be able to access the members of my class when it is not a member of my class. I always use something like the following:
class Stuff {
//...
static UINT ThreadStart(LPVOID parameter);
UINT Thread();
};
UINT Stuff::ThreadStart(LPVOID parameter)
{
Stuff *_this = (Stuff *)parameter;
return _this->Thread();
}
UINT Stuff::Thread()
{
//...
}
//...
AfxBeginThread(ThreadStart,(LPVOID)this);
The static member function matches the prototype required by AfxBeginThread(). You use the parameter to pass a pointer to an instance of your class. In my example, I passed the this pointer, which means I'm starting the thread from another member function of the class. The function that does the actual work of the thread is called Thread(), and since it is a member function, it can access other members of the Stuff class.
Software Zen: delete this;