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

C / C++ / MFC

 
GeneralRe: having problem terminating a thread Pin
alberthyc2-Aug-07 9:51
alberthyc2-Aug-07 9:51 
GeneralRe: having problem terminating a thread Pin
Randor 2-Aug-07 10:33
professional Randor 2-Aug-07 10:33 
GeneralRe: having problem terminating a thread Pin
alberthyc2-Aug-07 10:47
alberthyc2-Aug-07 10:47 
GeneralRe: having problem terminating a thread Pin
led mike2-Aug-07 10:49
led mike2-Aug-07 10:49 
GeneralRe: having problem terminating a thread Pin
Mark Salsbery2-Aug-07 10:56
Mark Salsbery2-Aug-07 10:56 
GeneralRe: having problem terminating a thread Pin
led mike2-Aug-07 11:01
led mike2-Aug-07 11:01 
GeneralRe: having problem terminating a thread Pin
alberthyc2-Aug-07 11:09
alberthyc2-Aug-07 11:09 
GeneralRe: having problem terminating a thread Pin
Tony Hill2-Aug-07 10:56
mveTony Hill2-Aug-07 10:56 
I tried your code in a simple dialog project and it works.

In your original post you state that it is looping with no explanation as to what it is doing.

I put an intensive processor loop in there and tried and got a termination using the TerminateThread which is what you describe.

Because your WaitSingleObject specifies that you should only wait 2 seconds for the object to be signalled, it may be because your thread function is not terminating within 2 seconds it is returning a WAIT_TIMEOUT and as you only check for a WAIT_OBJECT_0 you assume that something has failed which is incorrect.

All that has happened in effect is the you got tired of waiting for it to complete and decide to kill it prematurely by incorrectly assuming that something must be wrong.

If your thread is not being signalled within the 2 seconds you specify I would assume that the problem lies in your thread function in that it takes too long to complete each pass through the while loop.

However without knowing what goes on in the loop it would be difficult to provide further guidance.
GeneralRe: having problem terminating a thread Pin
alberthyc2-Aug-07 11:07
alberthyc2-Aug-07 11:07 
GeneralRe: having problem terminating a thread Pin
Randor 2-Aug-07 11:07
professional Randor 2-Aug-07 11:07 
GeneralRe: having problem terminating a thread Pin
alberthyc2-Aug-07 11:13
alberthyc2-Aug-07 11:13 
AnswerRe: having problem terminating a thread Pin
David Crow2-Aug-07 10:46
David Crow2-Aug-07 10:46 
QuestionDiffrenece between executing a program within IDE and Windows Explorer Pin
Joseph Marzbani2-Aug-07 8:41
Joseph Marzbani2-Aug-07 8:41 
AnswerRe: Diffrenece between executing a program within IDE and Windows Explorer Pin
Randor 2-Aug-07 10:44
professional Randor 2-Aug-07 10:44 
QuestionRe: Diffrenece between executing a program within IDE and Windows Explorer Pin
David Crow2-Aug-07 10:47
David Crow2-Aug-07 10:47 
QuestionReport view list control drawing difference when manifest file used Pin
Keith Worden2-Aug-07 6:29
Keith Worden2-Aug-07 6:29 
QuestionMFC: CListCtrl derived class, "creportctrl" tutorial problem Pin
Sternocera2-Aug-07 5:15
Sternocera2-Aug-07 5:15 
QuestionRe: MFC: CListCtrl derived class, "creportctrl" tutorial problem Pin
David Crow2-Aug-07 5:17
David Crow2-Aug-07 5:17 
AnswerRe: MFC: CListCtrl derived class, "creportctrl" tutorial problem Pin
Sternocera2-Aug-07 5:19
Sternocera2-Aug-07 5:19 
QuestionRe: MFC: CListCtrl derived class, "creportctrl" tutorial problem Pin
David Crow2-Aug-07 5:27
David Crow2-Aug-07 5:27 
AnswerRe: MFC: CListCtrl derived class, "creportctrl" tutorial problem Pin
Sternocera2-Aug-07 5:29
Sternocera2-Aug-07 5:29 
AnswerRe: MFC: CListCtrl derived class, "creportctrl" tutorial problem Pin
led mike2-Aug-07 7:15
led mike2-Aug-07 7:15 
GeneralRe: MFC: CListCtrl derived class, "creportctrl" tutorial problem Pin
Sternocera2-Aug-07 7:21
Sternocera2-Aug-07 7:21 
GeneralRe: MFC: CListCtrl derived class, "creportctrl" tutorial problem Pin
led mike2-Aug-07 7:31
led mike2-Aug-07 7:31 
GeneralRe: MFC: CListCtrl derived class, "creportctrl" tutorial problem Pin
Sternocera2-Aug-07 7:35
Sternocera2-Aug-07 7:35 

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.