Click here to Skip to main content
15,921,203 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Erase external files Pin
chadell27-Nov-03 1:59
chadell27-Nov-03 1:59 
GeneralRe: Erase external files Pin
Neville Franks27-Nov-03 0:25
Neville Franks27-Nov-03 0:25 
GeneralRe: Erase external files Pin
Prakash Nadar27-Nov-03 1:01
Prakash Nadar27-Nov-03 1:01 
Generalstore and retrieve .bmp using sql server 2000 and vc++ 6.0 Pin
mctpursuer26-Nov-03 23:09
mctpursuer26-Nov-03 23:09 
GeneralA confusing problem... Pin
Rob Manderson26-Nov-03 23:03
protectorRob Manderson26-Nov-03 23:03 
GeneralRe: A confusing problem... Pin
Ryan Roberts26-Nov-03 23:42
Ryan Roberts26-Nov-03 23:42 
GeneralRe: A confusing problem... Pin
Rob Manderson26-Nov-03 23:48
protectorRob Manderson26-Nov-03 23:48 
GeneralRe: A confusing problem... Pin
Mike Dimmick27-Nov-03 1:48
Mike Dimmick27-Nov-03 1:48 
I think you've deadlocked.

According to your description, you set the event object to signal that the update thread should shut down, then wait for the update thread to quit. While waiting, the UI thread is blocked.

I assume that the update thread looks something like:
while ( WAIT_TIMEOUT == WaitForSingleObject( hUpdateQuitEvent, 0 ) )
{
   /* A */
   m_pList->InsertItem( /* ... */ );
}
If the UI thread runs at point A, sets the event and then waits on the thread handle before the update thread continues to the next line, the UI thread is blocked while the update thread calls SendMessage.

SendMessage does indeed do a direct call, if and only if the thread calling SendMessage is the same one that created the window. Otherwise, SendMessage adds a message to the window's thread's message queue (which takes priority over posted messages) and blocks until either the windows procedure returns or until it calls ReplyMessage. The sent message is processed the next time a message is retrieved by the window's thread (within GetMessage - a sent message does not cause this APIs to return).

I recommend getting rid of your update thread completely, as it appears to be an unnecessary complication, and posting a custom message in the WM_USER range (with PostMessage) to your UI thread from the monitor thread, where you would have signalled your update thread. That message will then be processed next time your UI thread is idle. You should then be able to shut down the monitor thread with impunity.
GeneralRe: A confusing problem... Pin
Rob Manderson27-Nov-03 8:49
protectorRob Manderson27-Nov-03 8:49 
GeneralRe: A confusing problem... Pin
Mike Dimmick27-Nov-03 9:11
Mike Dimmick27-Nov-03 9:11 
GeneralRe: A confusing problem... Pin
Neville Franks27-Nov-03 0:23
Neville Franks27-Nov-03 0:23 
GeneralRe: A confusing problem... Pin
Rob Manderson27-Nov-03 8:50
protectorRob Manderson27-Nov-03 8:50 
GeneralRe: A confusing problem... Pin
Neville Franks27-Nov-03 9:10
Neville Franks27-Nov-03 9:10 
GeneralRe: A confusing problem... Pin
Roger Allen27-Nov-03 3:31
Roger Allen27-Nov-03 3:31 
GeneralDrop-Down toolbar Pin
shyampriya26-Nov-03 22:56
shyampriya26-Nov-03 22:56 
GeneralTemplate class in a vector Pin
Jerome Conus26-Nov-03 22:35
Jerome Conus26-Nov-03 22:35 
GeneralRe: Template class in a vector Pin
Mike Dimmick27-Nov-03 2:01
Mike Dimmick27-Nov-03 2:01 
GeneralOutlook Express please help Pin
Jump_Around26-Nov-03 21:57
Jump_Around26-Nov-03 21:57 
GeneralSpawning error Pin
Cedric Moonen26-Nov-03 21:51
Cedric Moonen26-Nov-03 21:51 
GeneralRe: Spawning error Pin
Prakash Nadar26-Nov-03 23:47
Prakash Nadar26-Nov-03 23:47 
GeneralRe: Spawning error Pin
Cedric Moonen26-Nov-03 23:57
Cedric Moonen26-Nov-03 23:57 
GeneralVisual C++ 6 and Oracle rman Pin
steffen241226-Nov-03 21:16
steffen241226-Nov-03 21:16 
GeneralI need your suggestions of building a network scan tool. Pin
mctpursuer26-Nov-03 20:56
mctpursuer26-Nov-03 20:56 
QuestionPrinter DC? Pin
murali_utr26-Nov-03 20:33
murali_utr26-Nov-03 20:33 
AnswerRe: Printer DC? Pin
Roger Allen27-Nov-03 3:36
Roger Allen27-Nov-03 3:36 

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.