Visual Studio hangs during Debugging a thread:

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

  1. PfisterHarald

    PfisterHarald New Member

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

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

    Code:
    ////////////////////////////////////////////
    // 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
            //CDialog::OnOK();
    }
    
    UINT CTestDlg::TestThread(LPVOID lpParam) {
    int _i;
            for (_i = 0; _i <= 10000000; _i++) {
                    _i = _i;
            }       // << BREAKPOINT is set here
            return(0);
    
    }
    
    ////////////////////////////////////////////
    // The following code was added to CTestDlg.h:
    typedef struct STRUCT_TINFTEST {
            bool bStop;
            bool bRuns;
    
    } struct_tinfTest;
    
    public:
            static UINT TestThread(LPVOID lpParam);
    protected:
            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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice