Debugging a multi-threaded C ++ application with a large thread pool

I have my own C ++ application running under VS2014 SP2 that uses a lot of multithreading using my own thread pool. Typically, an application will have> 32 threads running at any given time, most of which will be idle most of the time. Is there any way in the debugger to see which threads in the thread view are idling (i.e., in the sleep function), because currently, if I interrupt execution, the debugger usually returns me to the sleeping part of the inactive thread;

UINT    _cdecl MyThreadFunc(LPVOID pParam)
{
    CMyThreadSlot *pThreadInfo = (CMyThreadSlot*)pParam;
    while (pThreadInfo->m_pManager->m_Active)
    {
        try
        {
            if (pThreadInfo->m_pActivity)
            {
                pThreadInfo->m_pActivity->Execute();
                pThreadInfo->m_pActivity = NULL;
            }
            else
                Sleep(50);  <-- breaking execution ends up here
        }
        catch (CUserException* e)
        {
            e->Delete();
            if (pThreadInfo->m_pActivity)
                if (pThreadInfo->m_pActivity->m_pThreadGroup)
                    pThreadInfo->m_pActivity->m_pThreadGroup->m_ExceptionThrown = TRUE;
        }
    }
    return CMyThreadManager::ExitOk;
}

, , , , . , , , , .

: , , Process Explorer, , , , , . , , .

+4
1

. Trick , , reset - . .

    CWinThread *pWinThread = AfxBeginThread(MyThreadFunc, MyThreadSlotObject, THREAD_PRIORITY_BELOW_NORMAL);
    MyThreadSlotObject->m_hThread = pWinThread->m_hThread;

:

        if (pThreadInfo->m_pActivity)
        {
            SetThreadPriority(pThreadInfo->m_hThread, THREAD_PRIORITY_NORMAL);
            pThreadInfo->m_pActivity->Execute();
            SetThreadPriority(pThreadInfo->m_hThread, THREAD_PRIORITY_BELOW_NORMAL);
            pThreadInfo->m_pActivity = NULL;
        }

: , , .

+3

All Articles