1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Visual Studio hangs during Debugging a thread:

Discussion in 'MFC' started by PfisterHarald, Sep 13, 2006.

  1. PfisterHarald

    PfisterHarald New Member

    Sep 13, 2006
    Likes Received:
    Trophy Points:
    VC++ 6.0 Enterprise edition
    WindowsXP SP2

    A Simple test project was generated with MFC app wizard (dialog based).

    // The following code was added to CTestDlg.cpp:
    void CTestDlg::OnOK() {
            // Start test
            m_pThread = AfxBeginThread(TestThread, &tinf_OnOkThread);
            m_hThread = m_pThread->m_hThread;    // Save Handle to ThreadFunction
    UINT CTestDlg::TestThread(LPVOID lpParam) {
    int _i;
            for (_i = 0; _i <= 10000000; _i++) {
                    _i = _i;
            }       // << BREAKPOINT is set here
    // The following code was added to CTestDlg.h:
    typedef struct STRUCT_TINFTEST {
            bool bStop;
            bool bRuns;
    } struct_tinfTest;
            static UINT TestThread(LPVOID lpParam);
            struct_tinfTest tinf_OnOkThread;
            CWinThread *m_pThread;          // pointer to thread-function
            HANDLE  m_hThread;              // handle to thread-function
            virtual void OnOK();
    After starting the program and pressing the Ok button the thread is started.
    The execution stops at the BREAKPOINT. Continue with F5 the execution stops
    again at the BREAKPOINT. Doing this about 300 times (or less if more
    instructions are in the for loop) Visual Studio hangs for about 30 seconds.
    In the toolbar "Debug" the commands "Restart" and "Stop Debugging" are
    enabled as shown when the Breakpoint is reached and the user may continue.
    The window title shows "test - Microsoft Visual C++ [run]" for the first 15
    seconds and "test - Microsoft Visual C++ [break]" for the next 15 seconds.
    During these times VS doesn't react on anything, even the complete system
    hangs. A change to another application is not possible (or extremely time
    intensive). Opening the Task Manager is not possible (or uses too much time).
    The options are to wait the 30 seconds or using Ctrl-Alt-Del and choose
    "Logout" (results in a dialog to terminate MSDEV that doesn't react).

    Is there anyone that knows the problem and a solution?
    Is it already a problem of VS or a system bug?

    Thanks for answer
    Pfister Harald

Share This Page