I have a native C++ application running under VS2014 SP2 that uses a lot of multi-threading using my own thread pool class. Typically, the application will have > 32 threads running at any one time, most of which will be idle much of the time. Is there any way in the debugger of seeing which threads in the the thread view are idling (i.e. in a sleep function), as presently, if I break execution the debugger typically brings me back to the sleeping part of an 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;
}
If I end up here after breaking, I currently have to trawl through the call stack for each thread to see what was actually executing which can be painful. Even if I break into other code, I'd still also like to know which other threads aren't sleeping and check what they are doing.
Edit: Ok, clunky enough solution, but firing up Process Explorer, right clicking on my running application, selecting properties threads allows me to sort threads by CPU usage, using the Thread ID of active threads then lets me find figure out which threads in use. Main flaw is that this has to be done prior to breaking the running app.
catch (CUserException* e)instead of justcatch (CUserException const & e). What advantages does pointer bring to your case? - Nawaz