Click here to Skip to main content
16,005,491 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralThanks for the help, everyone Pin
Bill Wilson28-Jan-02 6:17
Bill Wilson28-Jan-02 6:17 
QuestionHow do I: Automate Outlook Express Pin
CMFC6.0VS.NETUser25-Jan-02 6:57
CMFC6.0VS.NETUser25-Jan-02 6:57 
AnswerRe: How do I: Automate Outlook Express Pin
Edd Porter25-Jan-02 13:02
Edd Porter25-Jan-02 13:02 
GeneralTransparency in Dialog images. Pin
Jon Newman25-Jan-02 6:48
Jon Newman25-Jan-02 6:48 
QuestionMonitor sockets? Pin
-Dy25-Jan-02 6:01
-Dy25-Jan-02 6:01 
AnswerRe: Monitor sockets? Pin
pba_25-Jan-02 6:37
pba_25-Jan-02 6:37 
AnswerRe: Monitor sockets? Pin
Chris Hafey26-Jan-02 8:31
Chris Hafey26-Jan-02 8:31 
GeneralTerminating a thread Pin
HomeNuke25-Jan-02 6:00
HomeNuke25-Jan-02 6:00 
I have been trying to terminate a thread I started in my application. I am writing a server application and have spun a seperate thread off for the server, that in turns spawns another thread when a client connects, and I am using Winsock 2.2. During the listen portion of the server thread I put it in a while loop more specifically:
while(1)
{
   //Code to listen and spawn thread goes here
}

However, I get a memory leak when I quit the application, since it is in a while loop the thread can not properly terminate. I have tried several methods in order to get it to terminate. Here is what I have tried:

In my ThreadParam struct I added a variable bool Stop. When I start the thread I set stop to false and in the while loop I use an if statement to check for Stop. If it is true I break out of the while loop so the thread can close safely. I change Stop to true in the WM_CLOSE message of the MAIN GUI interface--No success.

Tried using a loop in the close function to make sure that the thread has stopped by checking the return value of ::GetExitCodeThread and making sure it doesn't return STILL_ACTIVE--No success

Current thoughts:

Even though this is a worker thread as defined by MFC I'm thinking of turning it into a UI thread so I can use PostQuitMessage and send a user defined message to thread to terminate.

Any suggestions to resolving this matter? Thanks in advance for any help.

HomeNuke
----
"Nuke'd Your Home, Yet?"
Run your own PostNuke based web server from home
http://www.homenuke.com
GeneralRe: Terminating a thread Pin
25-Jan-02 6:31
suss25-Jan-02 6:31 
GeneralRe: Terminating a thread Pin
pba_25-Jan-02 6:47
pba_25-Jan-02 6:47 
GeneralRe: Terminating a thread Pin
Ernest Laurentin25-Jan-02 6:50
Ernest Laurentin25-Jan-02 6:50 
GeneralRe: Terminating a thread Pin
HomeNuke25-Jan-02 7:04
HomeNuke25-Jan-02 7:04 
GeneralRe: Terminating a thread Pin
25-Jan-02 7:01
suss25-Jan-02 7:01 
GeneralRe: Terminating a thread Pin
Matt Gullett25-Jan-02 7:42
Matt Gullett25-Jan-02 7:42 
GeneralRe: Terminating a thread Pin
HomeNuke25-Jan-02 7:51
HomeNuke25-Jan-02 7:51 
GeneralRe: Terminating a thread Pin
Ernest Laurentin25-Jan-02 8:47
Ernest Laurentin25-Jan-02 8:47 
GeneralRe: Terminating a thread Pin
HomeNuke25-Jan-02 8:52
HomeNuke25-Jan-02 8:52 
GeneralRe: Terminating a thread Pin
Ernest Laurentin25-Jan-02 9:25
Ernest Laurentin25-Jan-02 9:25 
GeneralRe: Terminating a thread Pin
HomeNuke25-Jan-02 9:28
HomeNuke25-Jan-02 9:28 
GeneralRe: Terminating a thread Pin
Ernest Laurentin25-Jan-02 10:29
Ernest Laurentin25-Jan-02 10:29 
GeneralRe: Terminating a thread Pin
HomeNuke25-Jan-02 11:28
HomeNuke25-Jan-02 11:28 
GeneralRe: Terminating a thread Pin
25-Jan-02 9:43
suss25-Jan-02 9:43 
GeneralRe: Terminating a thread Pin
HomeNuke25-Jan-02 9:42
HomeNuke25-Jan-02 9:42 
GeneralRe: Terminating a thread Pin
25-Jan-02 10:22
suss25-Jan-02 10:22 
GeneralDirectory search Pin
Stan the man25-Jan-02 6:02
Stan the man25-Jan-02 6:02 

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.