Click here to Skip to main content
15,887,746 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: files after compilation Pin
Rozis16-Sep-09 13:10
Rozis16-Sep-09 13:10 
Questiontop down and bottom up apporach Pin
hrishiS16-Sep-09 1:30
hrishiS16-Sep-09 1:30 
AnswerRe: top down and bottom up apporach Pin
Nuri Ismail16-Sep-09 1:48
Nuri Ismail16-Sep-09 1:48 
QuestionIn System Tray Icon Ballon not displayed in Windows XP. Pin
Le@rner16-Sep-09 0:41
Le@rner16-Sep-09 0:41 
AnswerRe: In System Tray Icon Ballon not displayed in Windows XP. Pin
Iain Clarke, Warrior Programmer16-Sep-09 1:19
Iain Clarke, Warrior Programmer16-Sep-09 1:19 
GeneralRe: In System Tray Icon Ballon not displayed in Windows XP. Pin
Le@rner21-Sep-09 2:47
Le@rner21-Sep-09 2:47 
AnswerRe: In System Tray Icon Ballon not displayed in Windows XP. Pin
«_Superman_»16-Sep-09 1:21
professional«_Superman_»16-Sep-09 1:21 
QuestionWaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Chesnokov Yuriy16-Sep-09 0:33
professionalChesnokov Yuriy16-Sep-09 0:33 
AnswerRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
«_Superman_»16-Sep-09 1:18
professional«_Superman_»16-Sep-09 1:18 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Chesnokov Yuriy16-Sep-09 1:51
professionalChesnokov Yuriy16-Sep-09 1:51 
AnswerRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 1:29
professional Randor 16-Sep-09 1:29 
AnswerRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Chesnokov Yuriy16-Sep-09 1:51
professionalChesnokov Yuriy16-Sep-09 1:51 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 2:29
professional Randor 16-Sep-09 2:29 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Roger Stoltz16-Sep-09 2:55
Roger Stoltz16-Sep-09 2:55 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 3:08
professional Randor 16-Sep-09 3:08 
AnswerRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Roger Stoltz16-Sep-09 4:07
Roger Stoltz16-Sep-09 4:07 
Hi David,


Randor wrote:
Describing it as 'better' sounds like an opinion.


Mmmm, it may be so, but I'd like to clarify my opinion. Wink | ;-)
If the OP's problem was that he called ::WaitForSingleObject() with an invalid handle, it would return immediately with WAIT_FAILED, so this cannot be the problem. If the handle is still valid ::WaitForSingleObject() will either return zero or wait as expected.
Your suggestion to duplicate the handle is to circumvent the fact that CWinThread will close the handle in its destructor, unless the m_bAutoDelete member is set to FALSE. In this case my opinion of 'better' is to fix it the MFC way since it was introduced by MFC.
I think it's cleaner and hence 'better', but whether that's 'better' or not is a matter of opinion.

For what it's worth I think the OP has created some kind of race condition that may end up in a deadlock where the spawned thread sends a message to the main thread. In the message handler call chain he then waits for the thread to finished.....


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown


GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 4:40
professional Randor 16-Sep-09 4:40 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Roger Stoltz16-Sep-09 5:34
Roger Stoltz16-Sep-09 5:34 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 7:04
professional Randor 16-Sep-09 7:04 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Chesnokov Yuriy16-Sep-09 7:22
professionalChesnokov Yuriy16-Sep-09 7:22 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 7:47
professional Randor 16-Sep-09 7:47 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Roger Stoltz16-Sep-09 7:59
Roger Stoltz16-Sep-09 7:59 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 8:51
professional Randor 16-Sep-09 8:51 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Roger Stoltz16-Sep-09 11:58
Roger Stoltz16-Sep-09 11:58 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 12:25
professional Randor 16-Sep-09 12:25 

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.