+ Reply to Thread
Results 1 to 2 of 2

Thread: How to check whether thread is still running or not?

  1. #1

    How to check whether thread is still running or not?

    How to check whether thread is still running or not?

  2. #2
    Following example creates a thread in MFC's dialog based application and then checks whether the thread it has just created is running or not!

    Code:
    bool IsThreadStillRunning(HANDLE hThread)
    {
    	bool bReturn = false ;
    	DWORD dwExitCode = 0;
    	if(GetExitCodeThread(hThread, &dwExitCode))
    	{
    		bReturn = (STILL_ACTIVE == dwExitCode) ;
    	}
    	
    	return bReturn ;
    }
    
    
    void CMyDialog::OnInitDialog()
    {
    	CWinThread *pWinThread = AfxBeginThread(ThreadFunc, NULL) ;
    
    	bool bIsThreadStillRunning = IsThreadStillRunning(pWinThread->m_hThread) ;
    }
    Last edited by Maxi; 03-07-2012 at 07:02 AM.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts