CDialog from CWinThread derived class hangs on ShowWindow(SH_HIDE) on shutdown
- From: "Barry" <Barry.True@xxxxxxxxx>
- Date: 24 May 2006 13:41:51 -0700
I've got a CDialog derived class that is wrapped inside of a
thread-safe wrapper that displays a progress dialog. I created a
CWinThread derived user interface thread class so that the dailog could
be moved out of the way of underlying dialogs while processing that
takes a long time could continue in the parent thread. I'm using
AfxBeginThread to create the thread and setting the m_bAutoDelete
property to FALSE so I can wait for the thread to terminate when the
parent needs to shut it down. When the thread is created the dialog
with the progress bar is displayed as expected. However when the
ExitInstance method trys to invoke a method in the wrapper class to
hide the dialog and destroy the window, the code hangs in the
ptrDlg->ShowWindow(SW_HIDE) method.
When the parent thread is completed processing it goes into a loop that
invokes PostThreadMessage to post a registered window message to the
child thread and WaitForSingleObject with the thread's handle to wait
for it to terminate. The message handler in the child thread is
invoking PostQuitMessage and the ExitInstance method is being invoked
as expected and is invoking a method on the wrapper class which goes
into a PeekMessage loop until the thread is ready to be joined and then
attempts to hide the dialog which hangs. The parent times out of the
WaitForSingleObject and loops back to post the message again. It
attempts this three times after which it gives up and sets the pointer
to the child thread to NULL. This makes the dialog disappear but I'm
concerned that things aren't being cleaned up properly in the thread
when this happens. Any clues as to why the ShowWindow is hanging?
.
- Follow-Ups:
- Re: CDialog from CWinThread derived class hangs on ShowWindow(SH_HIDE) on shutdown
- From: Scott McPhillips [MVP]
- Re: CDialog from CWinThread derived class hangs on ShowWindow(SH_HIDE) on shutdown
- Prev by Date: DLL Question
- Next by Date: Re: debugger exception
- Previous by thread: DLL Question
- Next by thread: Re: CDialog from CWinThread derived class hangs on ShowWindow(SH_HIDE) on shutdown
- Index(es):
Relevant Pages
|
Loading