|
From: bfarcasanu on 9 May 2008 06:37 I have a very weird problem... In a dialog based app, when a button is clicked, I call AfxBeginThread() to create a new worker therad (not a UI one). The thread is created suspended, and after that started. The problem is that AfxBeginThread hangs every single time (both debug and release). It never returns. To make this even more weird, it never hangs while the debugger is attached, even though no breakpoints are set. I mention that I am absolutely sure that it is AfxBeginThread that hangs, I put some calls to MessageBox() and / or output to log files before and after it, so I am amsolutely sure it is it that hangs. I also mention that I'm not doing this during a call to DllMain, but during an MFC event handler (dialog button being clicked). Thanks, Bogdan.
From: Ismo Salonen on 9 May 2008 07:48 bfarcasanu(a)gmail.com wrote: > I have a very weird problem... In a dialog based app, when a button is > clicked, I call AfxBeginThread() to create a new worker therad (not a > UI one). The thread is created suspended, and after that started. The > problem is that AfxBeginThread hangs every single time (both debug and > release). It never returns. To make this even more weird, it never > hangs while the debugger is attached, even though no breakpoints are > set. > > I mention that I am absolutely sure that it is AfxBeginThread that > hangs, I put some calls to MessageBox() and / or output to log files > before and after it, so I am amsolutely sure it is it that hangs. I > also mention that I'm not doing this during a call to DllMain, but > during an MFC event handler (dialog button being clicked). > > Thanks, > > Bogdan. Does it hand even if you substitute a dummy function for the thread ? could you attach debugger when it hangs ? then break and check where it is hung. There are about one gazillion of reasons why it could hang, perhaps there is a loader lock ( some dllmain trying to do something wierd ? ) ismo
From: Joseph M. Newcomer on 9 May 2008 10:35 On Fri, 9 May 2008 03:37:48 -0700 (PDT), bfarcasanu(a)gmail.com wrote: >I have a very weird problem... In a dialog based app, when a button is >clicked, I call AfxBeginThread() to create a new worker therad (not a >UI one). The thread is created suspended, and after that started. The >problem is that AfxBeginThread hangs every single time (both debug and >release). It never returns. To make this even more weird, it never >hangs while the debugger is attached, even though no breakpoints are >set. **** This is suggestive of some fundamental design problem. First, when you say AfxBeginThread "hangs", you have to describe a whole lot more about the context in which this occurs. What is the thread doing? What shared state is involved? What synchronization mechanisms are involved? There is no way to debug such a problem via ethereal vibrations. A debugger, by its presence, changes the timing, and it sounds suspiciously like you have a time-sensitive bug in your design. Most likely there is some kind of deadlock. However, using the Break option in the debugger, examing the thread contexts, and seeing where the thread is currently executing will possibly provide useful information. Note that if you have DLLs that might handle DLL_THREAD_ATTACH events, and one of these events goes into an infinite loop, you will never return from AfxBeginThread. So what DLLs are you using (note that in general, handling DLL_THREAD_ATTACH events is a Very Dangerous Thing To Do, and opens you to so many problems that the best thing to do is to avoid all the problems by never doing this). joe > >I mention that I am absolutely sure that it is AfxBeginThread that >hangs, I put some calls to MessageBox() and / or output to log files >before and after it, so I am amsolutely sure it is it that hangs. I >also mention that I'm not doing this during a call to DllMain, but >during an MFC event handler (dialog button being clicked). > >Thanks, > >Bogdan. Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
|
Pages: 1 Prev: Vista installations (again) Next: Prevent Dialog from Being Shown in OnShowWindow |