Click here to Skip to main content
15,914,163 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralGetFocus() returns NULL Pin
Swinefeaster7-Mar-04 18:58
Swinefeaster7-Mar-04 18:58 
GeneralRe: GetFocus() returns NULL Pin
Prakash Nadar7-Mar-04 19:07
Prakash Nadar7-Mar-04 19:07 
Generaldirectx 8 / 9 issues Pin
siniani7-Mar-04 16:24
siniani7-Mar-04 16:24 
GeneralThread programming question Pin
Madmaximus7-Mar-04 15:41
Madmaximus7-Mar-04 15:41 
GeneralRe: Thread programming question Pin
Prakash Nadar7-Mar-04 15:48
Prakash Nadar7-Mar-04 15:48 
GeneralRe: Thread programming question Pin
Madmaximus7-Mar-04 16:19
Madmaximus7-Mar-04 16:19 
GeneralRe: Thread programming question Pin
Prakash Nadar7-Mar-04 16:38
Prakash Nadar7-Mar-04 16:38 
GeneralRe: Thread programming question Pin
Curi0us_George7-Mar-04 16:43
Curi0us_George7-Mar-04 16:43 
The simplest answer is yes, you definitely need to delete the ThreadA that pThreadA points to.

There are a few other things that strike me as notable/strange.

1. FuncPtr is static, and thus has no "this" context. "delete this" will result in a compile time error. Any member functions/variables will also be inaccessible from FuncPtr.

2. If you want to use "delete this", you need FuncPtr to accept a pointer to a the ThreadA object and use it to call an instance function.

e.g.:
int FuncPtr2()
{
// do stuff
return 1;
}

static int FuncPtr(void * param)
{
return ((ThreadA *)param)->FuncPtr2();
}

Now FuncPtr2 has an appropriate context to use "delete this". However, this is probably a bad idea. In my experience, it sometimes leads to strange bugs, and it's just not worth it. In addition, the behavior of "delete this" is undefined if the object "this" points to was allocated on the stack.

My suggestion would be to put some sort of checking mechanism into main. (I assume this is what Wait() is doing.) At the end of the function (or at the end of the relevant section), use this checking mechanism to wait for the thread to complete, and then delete the ThreadA object in the main method.
Generalhot to set the step value in spin Pin
Mughi7-Mar-04 15:26
Mughi7-Mar-04 15:26 
GeneralRe: hot to set the step value in spin Pin
Prakash Nadar8-Mar-04 1:10
Prakash Nadar8-Mar-04 1:10 
GeneralRe: hot to set the step value in spin Pin
David Crow8-Mar-04 4:47
David Crow8-Mar-04 4:47 
GeneralRe: hot to set the step value in spin Pin
Roger Wright8-Mar-04 9:21
professionalRoger Wright8-Mar-04 9:21 
GeneralRe: hot to set the step value in spin Pin
David Crow8-Mar-04 9:28
David Crow8-Mar-04 9:28 
GeneralRe: hot to set the step value in spin Pin
Roger Wright8-Mar-04 10:09
professionalRoger Wright8-Mar-04 10:09 
GeneralNeed opinions on proposed Plugin framework Pin
Anonymous7-Mar-04 15:13
Anonymous7-Mar-04 15:13 
GeneralRe: Need opinions on proposed Plugin framework Pin
Prakash Nadar7-Mar-04 15:43
Prakash Nadar7-Mar-04 15:43 
GeneralI need help understanding this part of DirectShow SDK Pin
Redbehelit7-Mar-04 15:10
Redbehelit7-Mar-04 15:10 
GeneralRe: I need help understanding this part of DirectShow SDK Pin
GDavy7-Mar-04 19:58
GDavy7-Mar-04 19:58 
GeneralC++ Question. Pin
WREY7-Mar-04 14:05
WREY7-Mar-04 14:05 
GeneralRe: C++ Question. Pin
Prakash Nadar7-Mar-04 14:58
Prakash Nadar7-Mar-04 14:58 
GeneralRe: C++ Question. Pin
WREY7-Mar-04 15:58
WREY7-Mar-04 15:58 
GeneralRe: C++ Question. Pin
Prakash Nadar7-Mar-04 16:11
Prakash Nadar7-Mar-04 16:11 
GeneralRe: C++ Question. Pin
Steve S7-Mar-04 22:20
Steve S7-Mar-04 22:20 
GeneralMFC: Can't insert controls after inserting an ActiveX Control!! Pin
Davex_7-Mar-04 12:21
Davex_7-Mar-04 12:21 
GeneralRe: MFC: Can't insert controls after inserting an ActiveX Control!! Pin
Davex_7-Mar-04 12:58
Davex_7-Mar-04 12:58 

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.