Subj : Re: Return value from worker thred when the working thread must be suspend after calculation??? To : comp.os.ms-windows.programmer.win32,microsoft.public.vc.language,comp.programming.threads From : David W. Poole, Jr. Date : Tue Aug 30 2005 02:28 am On Mon, 29 Aug 2005 22:14:25 -0700, "Alexander Grigoriev" was understood to have stated the following: >You should not access windows of the main thread from the secondary thread. >This may lead to deadlocks. Use PostMessage to communicate between threads. Ok, I'll buy using PostMessage() over SendMessage() to have a worker thread update the user interface as a safer alternative. Of personal interest though is how this can lead to a deadlock condition. In the applications where I utilize this technique, when a worker thread is initiated, the parameters are read from the appropriate controls, and the values are stuffed into a structure that is passed to the worker thread. Thus, the worker thread no longer requires any input from the user interface; it only needs to update the UI on occasion; say for progress information while the thread is active, and for parametric information upon the thread's completion. How can this lead to a deadlock, even with SendMessage(), as the worker thread never tries to obtain information from the user interface? There's never anything the worker thread is waiting on, and the user interface thread doesn't have any code other than the code that very quickly handles messages? .