Click here to Skip to main content
15,885,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Looking for solid C+Tree or C*-Tree source Pin
EXTEIDE10-Feb-06 6:40
EXTEIDE10-Feb-06 6:40 
GeneralRe: Looking for solid C+Tree or C*-Tree source Pin
Joe Woodbury10-Feb-06 6:47
professionalJoe Woodbury10-Feb-06 6:47 
GeneralRe: Looking for solid C+Tree or C*-Tree source Pin
EXTEIDE10-Feb-06 7:05
EXTEIDE10-Feb-06 7:05 
AnswerRe: Looking for solid C+Tree or C*-Tree source Pin
Jörgen Sigvardsson10-Feb-06 12:21
Jörgen Sigvardsson10-Feb-06 12:21 
QuestionHelp With VC++ SOcket Programming using MFCs Pin
alienattack10-Feb-06 6:13
alienattack10-Feb-06 6:13 
AnswerRe: Help With VC++ SOcket Programming using MFCs Pin
EXTEIDE10-Feb-06 6:24
EXTEIDE10-Feb-06 6:24 
AnswerRe: Help With VC++ SOcket Programming using MFCs Pin
ThatsAlok13-Feb-06 21:38
ThatsAlok13-Feb-06 21:38 
QuestionProper way to terminate a thead? Pin
masnu10-Feb-06 4:49
masnu10-Feb-06 4:49 
All the articles I have read state that all threads must be terminated before the main thread exits or the program will still be resident in memory.

The question then becomes, how to properly terminate all worker threads?

I have the following:

void CClient::StopThread()<br />
{<br />
	m_bRunning = false;<br />
	WaitForSingleObject(m_pThread->m_hThread, INFINITE);<br />
<br />
	delete m_pThread;<br />
}


And the worker thread is defined as:

UINT CClient::WorkerThread() <br />
{<br />
<br />
	while(m_bRunning)<br />
	{<br />
		//Do some work.....<br />
	}<br />
<br />
	AfxEndThread(0,0);<br />
//Signal here???<br />
<br />
	return 0;<br />
}


The problem is that the program hangs after I call the StopThread function. I am sure I need to signal the function that my thread has terminated but, since I am new to the MFC and multithreaded programming, I am not sure where to do that.

Any help is appreciated. Thanks.
AnswerRe: Proper way to terminate a thead? Pin
Roger Stoltz10-Feb-06 5:24
Roger Stoltz10-Feb-06 5:24 
GeneralRe: Proper way to terminate a thead? Pin
masnu10-Feb-06 6:42
masnu10-Feb-06 6:42 
AnswerRe: Proper way to terminate a thead? Pin
Stephen Hewitt11-Feb-06 0:25
Stephen Hewitt11-Feb-06 0:25 
QuestionList of error codes Pin
Spykraft10-Feb-06 4:04
Spykraft10-Feb-06 4:04 
AnswerRe: List of error codes Pin
toxcct10-Feb-06 4:08
toxcct10-Feb-06 4:08 
GeneralRe: List of error codes Pin
Spykraft10-Feb-06 4:18
Spykraft10-Feb-06 4:18 
QuestionRe: List of error codes Pin
David Crow10-Feb-06 4:26
David Crow10-Feb-06 4:26 
AnswerRe: List of error codes Pin
mukherjee12410-Feb-06 22:17
mukherjee12410-Feb-06 22:17 
GeneralRe: List of error codes Pin
Blake Miller13-Feb-06 4:19
Blake Miller13-Feb-06 4:19 
AnswerRe: List of error codes Pin
James R. Twine10-Feb-06 8:53
James R. Twine10-Feb-06 8:53 
AnswerRe: List of error codes Pin
Michael Dunn10-Feb-06 11:14
sitebuilderMichael Dunn10-Feb-06 11:14 
GeneralRe: List of error codes Pin
mukherjee12410-Feb-06 22:20
mukherjee12410-Feb-06 22:20 
GeneralRe: List of error codes Pin
Spykraft10-Feb-06 22:24
Spykraft10-Feb-06 22:24 
QuestionHow to hide scrollbar? Pin
Temp8310-Feb-06 3:55
Temp8310-Feb-06 3:55 
AnswerRe: How to hide scrollbar? Pin
includeh1010-Feb-06 5:42
includeh1010-Feb-06 5:42 
QuestionSpeed again Pin
hint_5410-Feb-06 3:40
hint_5410-Feb-06 3:40 
AnswerRe: Speed again Pin
toxcct10-Feb-06 3:45
toxcct10-Feb-06 3:45 

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.