Click here to Skip to main content
15,901,368 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: [MFC] Keep thread alive until application exits Pin
Erudite_Eric26-Sep-11 23:43
Erudite_Eric26-Sep-11 23:43 
GeneralRe: [MFC] Keep thread alive until application exits Pin
Albert Holguin27-Sep-11 4:46
professionalAlbert Holguin27-Sep-11 4:46 
GeneralRe: [MFC] Keep thread alive until application exits Pin
Rajesh R Subramanian27-Sep-11 7:26
professionalRajesh R Subramanian27-Sep-11 7:26 
GeneralRe: [MFC] Keep thread alive until application exits Pin
Albert Holguin27-Sep-11 7:30
professionalAlbert Holguin27-Sep-11 7:30 
GeneralRe: [MFC] Keep thread alive until application exits Pin
Albert Holguin27-Sep-11 7:35
professionalAlbert Holguin27-Sep-11 7:35 
AnswerRe: [MFC] Keep thread alive until application exits Pin
Chuck O'Toole27-Sep-11 4:11
Chuck O'Toole27-Sep-11 4:11 
GeneralRe: [MFC] Keep thread alive until application exits Pin
Albert Holguin27-Sep-11 7:51
professionalAlbert Holguin27-Sep-11 7:51 
GeneralRe: [MFC] Keep thread alive until application exits Pin
Chuck O'Toole27-Sep-11 8:38
Chuck O'Toole27-Sep-11 8:38 
In my opinion, interthread activities should be explicitly stated rather than rely on side effects of other things.

A "permission to exit" signal is one way of formalizing those activities. "Permission to start" is another. The fact that a thread was created doesn't necessarily mean that it can immediately being doing processing. My threads always go through several stages:

1) Initialization at the start address of the thread
2) Signals an "initialization done" event to allow the main thread to create more, knowing that any data structures, other events / objects are created and that the created thread is ready to run
3) Waits for a "permission to start" event. This allows the main thread to delay start of the thread until other threads are created and ensures that subsequent threads have created their objects that may be necessary for interthread communication to work.
4) enters the "run state" where it is now doing its job
5) "permission to exit" is optional and only when you want the "dance of the threads" to end in an orderly fashion.

You want this orderly approach to startup and shutdown to ensure that if you create many threads, some of which need to communicate with each other, those threads do not run into timing problems and access objects that may not be created / initialized yet by other threads.

Also, I have no idea why you downvoted my answer, it was not wrong, just not to your liking.
GeneralRe: [MFC] Keep thread alive until application exits Pin
Albert Holguin27-Sep-11 9:24
professionalAlbert Holguin27-Sep-11 9:24 
AnswerRe: [MFC] Keep thread alive until application exits Pin
Albert Holguin27-Sep-11 4:55
professionalAlbert Holguin27-Sep-11 4:55 
AnswerRe: [MFC] Keep thread alive until application exits Pin
Roger Allen27-Sep-11 6:10
Roger Allen27-Sep-11 6:10 
GeneralRe: [MFC] Keep thread alive until application exits Pin
Chris Meech27-Sep-11 6:29
Chris Meech27-Sep-11 6:29 
GeneralRe: [MFC] Keep thread alive until application exits Pin
Rajesh R Subramanian27-Sep-11 7:31
professionalRajesh R Subramanian27-Sep-11 7:31 
GeneralRe: [MFC] Keep thread alive until application exits Pin
Albert Holguin27-Sep-11 7:32
professionalAlbert Holguin27-Sep-11 7:32 
GeneralRe: [MFC] Keep thread alive until application exits Pin
Rajesh R Subramanian27-Sep-11 7:39
professionalRajesh R Subramanian27-Sep-11 7:39 
GeneralRe: [MFC] Keep thread alive until application exits Pin
Albert Holguin27-Sep-11 7:42
professionalAlbert Holguin27-Sep-11 7:42 
AnswerRe: [MFC] Keep thread alive until application exits Pin
Rajesh R Subramanian27-Sep-11 7:30
professionalRajesh R Subramanian27-Sep-11 7:30 
AnswerRe: [MFC] Keep thread alive until application exits Pin
David Crow27-Sep-11 16:00
David Crow27-Sep-11 16:00 
QuestionIs there any library which can detect the faulty statement at runtime? Pin
rahul.kulshreshtha26-Sep-11 22:05
rahul.kulshreshtha26-Sep-11 22:05 
AnswerRe: Is there any library which can detect the faulty statement at runtime? Pin
Madhu Nair26-Sep-11 23:17
Madhu Nair26-Sep-11 23:17 
QuestionRe: Is there any library which can detect the faulty statement at runtime? Pin
rahul.kulshreshtha27-Sep-11 1:25
rahul.kulshreshtha27-Sep-11 1:25 
AnswerRe: Is there any library which can detect the faulty statement at runtime? Pin
Rolf Kristensen27-Sep-11 8:20
Rolf Kristensen27-Sep-11 8:20 
QuestionErranous behavouir in Modless Dialog Pin
Amrit Agr26-Sep-11 21:30
Amrit Agr26-Sep-11 21:30 
SuggestionRe: Erranous behavouir in Modless Dialog Pin
Madhu Nair26-Sep-11 21:59
Madhu Nair26-Sep-11 21:59 
GeneralRe: Erranous behavouir in Modless Dialog Pin
Amrit Agr26-Sep-11 22:37
Amrit Agr26-Sep-11 22:37 

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.