Click here to Skip to main content
15,884,237 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Roger Stoltz16-Sep-09 12:51
Roger Stoltz16-Sep-09 12:51 
Well, the OP's problem could still be the one we've been discussing.
There is a possibility that the handled gets recycled between thread termination and the call to ::WaitForSingleObject(). When he claims that the thread is already terminated in 99% of the cases I doubt he really checks the return value; the wait may have failed since the handle has been closed but he doesn't care because it means that the thread doesn't run any longer.

As I wrote earlier I still think he has introduced a race condition where the worker thread somehow sends a message to the main thread instead of posting. If the main thread has already assumed its waiting state on the thread handle the deadlock is a reality.
This is in my opinion the most common reason for deadlocks when it comes to multithreading and would most definitely result in the behaviour he has described.
It may be that he's calling a framework function that disguises the ::SendMessage() call.

The probability for a design flaw I guess is very close to 100%.

I will have a good night; it's almost 1:00AM in Sweden and I'm about to hit the sack.
I wish you a good night as well!

--
Rog


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


AnswerRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Stuart Dootson16-Sep-09 1:58
professionalStuart Dootson16-Sep-09 1:58 
AnswerRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Jeff Archer16-Sep-09 2:47
Jeff Archer16-Sep-09 2:47 
QuestionExiting an MFC ActiveX Pin
Opa Knack15-Sep-09 22:41
Opa Knack15-Sep-09 22:41 
AnswerRe: Exiting an MFC ActiveX Pin
Stuart Dootson16-Sep-09 0:28
professionalStuart Dootson16-Sep-09 0:28 
AnswerRe: Exiting an MFC ActiveX Pin
Roger Stoltz16-Sep-09 0:38
Roger Stoltz16-Sep-09 0:38 
AnswerRe: Exiting an MFC ActiveX Pin
Randor 16-Sep-09 1:13
professional Randor 16-Sep-09 1:13 
QuestionAuto login a user in XP, after logoff Pin
SummerBulb15-Sep-09 21:59
SummerBulb15-Sep-09 21:59 
AnswerRe: Auto login a user in XP, after logoff Pin
«_Superman_»15-Sep-09 22:27
professional«_Superman_»15-Sep-09 22:27 
GeneralRe: Auto login a user in XP, after logoff Pin
SummerBulb15-Sep-09 22:32
SummerBulb15-Sep-09 22:32 
GeneralRe: Auto login a user in XP, after logoff Pin
SummerBulb15-Sep-09 22:45
SummerBulb15-Sep-09 22:45 
QuestionDifference between C++ and VC++ Pin
hrishiS15-Sep-09 21:09
hrishiS15-Sep-09 21:09 
AnswerRe: Difference between C++ and VC++ Pin
CPallini15-Sep-09 21:19
mveCPallini15-Sep-09 21:19 
AnswerRe: Difference between C++ and VC++ Pin
QuickDeveloper15-Sep-09 21:32
QuickDeveloper15-Sep-09 21:32 
GeneralRe: Difference between C++ and VC++ Pin
CPallini15-Sep-09 22:00
mveCPallini15-Sep-09 22:00 
GeneralRe: Difference between C++ and VC++ Pin
hrishiS16-Sep-09 1:04
hrishiS16-Sep-09 1:04 
QuestionHow to load a file in help ? Pin
deadlyabbas15-Sep-09 20:31
deadlyabbas15-Sep-09 20:31 
AnswerRe: How to load a file in help ? Pin
Iain Clarke, Warrior Programmer15-Sep-09 21:06
Iain Clarke, Warrior Programmer15-Sep-09 21:06 

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.