Click here to Skip to main content
15,898,588 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Question about Threads Pin
Nick_Kisialiou16-Feb-06 19:12
Nick_Kisialiou16-Feb-06 19:12 
AnswerRe: Question about Threads Pin
QuickDeveloper16-Feb-06 19:16
QuickDeveloper16-Feb-06 19:16 
AnswerRe: Question about Threads Pin
Stephen Hewitt16-Feb-06 19:47
Stephen Hewitt16-Feb-06 19:47 
GeneralRe: Question about Threads Pin
Nick_Kisialiou16-Feb-06 19:54
Nick_Kisialiou16-Feb-06 19:54 
GeneralRe: Question about Threads Pin
Stephen Hewitt16-Feb-06 19:58
Stephen Hewitt16-Feb-06 19:58 
GeneralRe: Question about Threads Pin
Nick_Kisialiou16-Feb-06 20:14
Nick_Kisialiou16-Feb-06 20:14 
GeneralRe: Question about Threads Pin
Stephen Hewitt19-Feb-06 11:11
Stephen Hewitt19-Feb-06 11:11 
AnswerRe: Question about Threads Pin
BadKarma16-Feb-06 20:53
BadKarma16-Feb-06 20:53 
When using a CWinThread object it is simple to terminate a thread.

1. if you have pointer to the object you can use:
CMyWinThread* pThread;
pThread->PostThreadMessage(WM_QUIT, NULL, NULL)
This will cause the thread, when idle to stop.
The thread will go to the ExitInstance function where the clean up can begin.

2. if you don't have a pointer to the object but you have the Thread Id, you can use:
DWORD dwThreadId;
::PostThreadMessage(dwThreadId, WM_QUIT, NULL, NULL);
With the same results

3. if you have neigther you need to have a common object to signal the thread to stop. This object
must be protected by thread synchronisation objects (like CMutex, CCriticalSection) or you can use
the CEvent to signal the thread to stop. I prefer one of the first two solutions because you don't
need to have a polling mechanisme to check if you need to stop or not. The third solution is preffered when the thread needs to be stopped during a lengthy operetation.

codito ergo sum
GeneralRe: Question about Threads [modified] Pin
BadKarma25-May-06 12:52
BadKarma25-May-06 12:52 
AnswerRe: Question about Threads Pin
Aqueel17-Feb-06 17:31
Aqueel17-Feb-06 17:31 
AnswerRe: Question about Threads Pin
ThatsAlok17-Feb-06 21:47
ThatsAlok17-Feb-06 21:47 
QuestionGetSafeHdc() allocates new memory or not Pin
anilksingh16-Feb-06 18:38
anilksingh16-Feb-06 18:38 
AnswerRe: GetSafeHdc() allocates new memory or not Pin
Ryan Binns16-Feb-06 19:45
Ryan Binns16-Feb-06 19:45 
AnswerRe: GetSafeHdc() allocates new memory or not Pin
John R. Shaw16-Feb-06 19:57
John R. Shaw16-Feb-06 19:57 
AnswerRe: GetSafeHdc() allocates new memory or not Pin
ThatsAlok17-Feb-06 3:42
ThatsAlok17-Feb-06 3:42 
QuestionQuestion about create simple image in c++/MFC Pin
Yanshof16-Feb-06 18:20
Yanshof16-Feb-06 18:20 
AnswerRe: Question about create simple image in c++/MFC Pin
Stephen Hewitt16-Feb-06 18:36
Stephen Hewitt16-Feb-06 18:36 
AnswerRe: Question about create simple image in c++/MFC Pin
John R. Shaw16-Feb-06 20:03
John R. Shaw16-Feb-06 20:03 
AnswerRe: Question about create simple image in c++/MFC Pin
ThatsAlok17-Feb-06 3:40
ThatsAlok17-Feb-06 3:40 
QuestionIssue with debug and release Pin
super16-Feb-06 16:03
professionalsuper16-Feb-06 16:03 
AnswerRe: Issue with debug and release Pin
ThatsAlok17-Feb-06 3:38
ThatsAlok17-Feb-06 3:38 
GeneralRe: Issue with debug and release Pin
Blake Miller17-Feb-06 4:26
Blake Miller17-Feb-06 4:26 
QuestionHow to realize my own shell format? Pin
Jerry New16-Feb-06 15:22
Jerry New16-Feb-06 15:22 
Questiondynamically creating controls Pin
britboyjohnson16-Feb-06 14:50
britboyjohnson16-Feb-06 14:50 
AnswerRe: dynamically creating controls Pin
Naveen16-Feb-06 16:16
Naveen16-Feb-06 16:16 

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.