Click here to Skip to main content
15,904,823 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to stop the thread if it's running? Pin
Cedric Moonen29-Apr-09 22:11
Cedric Moonen29-Apr-09 22:11 
GeneralRe: How to stop the thread if it's running? Pin
Rajesh R Subramanian29-Apr-09 22:19
professionalRajesh R Subramanian29-Apr-09 22:19 
GeneralRe: How to stop the thread if it's running? Pin
CPallini29-Apr-09 21:40
mveCPallini29-Apr-09 21:40 
GeneralRe: How to stop the thread if it's running? [modified] Pin
Rajesh R Subramanian29-Apr-09 22:00
professionalRajesh R Subramanian29-Apr-09 22:00 
NewsRe: How to stop the thread if it's running? Pin
Roger Stoltz29-Apr-09 22:26
Roger Stoltz29-Apr-09 22:26 
GeneralRe: How to stop the thread if it's running? Pin
Rajesh R Subramanian29-Apr-09 22:30
professionalRajesh R Subramanian29-Apr-09 22:30 
GeneralRe: How to stop the thread if it's running? Pin
Roger Stoltz29-Apr-09 22:35
Roger Stoltz29-Apr-09 22:35 
GeneralRe: How to stop the thread if it's running? Pin
Rajesh R Subramanian29-Apr-09 22:51
professionalRajesh R Subramanian29-Apr-09 22:51 
QuestionRe: How to stop the thread if it's running? Pin
CPallini29-Apr-09 22:42
mveCPallini29-Apr-09 22:42 
AnswerRe: How to stop the thread if it's running? Pin
Rajesh R Subramanian29-Apr-09 22:49
professionalRajesh R Subramanian29-Apr-09 22:49 
AnswerRe: How to stop the thread if it's running? Pin
Roger Stoltz29-Apr-09 22:52
Roger Stoltz29-Apr-09 22:52 
GeneralRe: How to stop the thread if it's running? Pin
Rajesh R Subramanian29-Apr-09 22:56
professionalRajesh R Subramanian29-Apr-09 22:56 
GeneralRe: How to stop the thread if it's running? Pin
Roger Stoltz29-Apr-09 23:04
Roger Stoltz29-Apr-09 23:04 
GeneralRe: How to stop the thread if it's running? Pin
Rajesh R Subramanian29-Apr-09 23:11
professionalRajesh R Subramanian29-Apr-09 23:11 
GeneralRe: How to stop the thread if it's running? Pin
CPallini29-Apr-09 23:34
mveCPallini29-Apr-09 23:34 
GeneralRe: How to stop the thread if it's running? Pin
CPallini29-Apr-09 23:32
mveCPallini29-Apr-09 23:32 
GeneralRe: How to stop the thread if it's running? Pin
Roger Stoltz29-Apr-09 23:40
Roger Stoltz29-Apr-09 23:40 
GeneralRe: How to stop the thread if it's running? Pin
CPallini29-Apr-09 23:44
mveCPallini29-Apr-09 23:44 
GeneralRe: How to stop the thread if it's running? Pin
Rajesh R Subramanian29-Apr-09 22:45
professionalRajesh R Subramanian29-Apr-09 22:45 
The issues with what you've done are:

1. You haven't shown us what you're doing inside the 'run' function. (can you please rename it to something other than run, I'm just terrified looking at the context - CWinThread::Run() ... you get the picture)

2. Your WaitFor... call does not 'wait', it just performs a check on a thread which might be running or might be dead, and then attempts to delete something which (again) may have been already dead (you haven't set the m_bAutoDelete to TRUE).

You may first try to run a thread successfully, and then try using Events with WaitFor... functions. Simulate processing with Sleep(10) within a loop (for learning purposes) and then shut it down gracefully by setting an Event. You need not 'delete' the CWinThread object, like I said. Give that excellent article another read, and you will be all set. Post a reply, if you're stuck somewhere.


It is a crappy thing, but it's life -^ Carlo Pallini

GeneralRe: How to stop the thread if it's running? Pin
mikert_200830-Apr-09 0:26
mikert_200830-Apr-09 0:26 
GeneralRe: How to stop the thread if it's running? Pin
Roger Stoltz30-Apr-09 2:54
Roger Stoltz30-Apr-09 2:54 
QuestionRe: How to stop the thread if it's running? Pin
David Crow30-Apr-09 3:58
David Crow30-Apr-09 3:58 
AnswerRe: How to stop the thread if it's running? Pin
David Crow30-Apr-09 4:07
David Crow30-Apr-09 4:07 
QuestionHow can I use C# Managed DLL into VC++ Application Pin
PankajB29-Apr-09 20:43
PankajB29-Apr-09 20:43 
AnswerRe: How can I use C# Managed DLL into VC++ Application Pin
Stuart Dootson29-Apr-09 20:50
professionalStuart Dootson29-Apr-09 20:50 

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.