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

Terminate Thread

Discussion in 'MFC' started by sukhrajsingh, Dec 17, 2010.

  1. sukhrajsingh

    sukhrajsingh New Member

    Joined:
    Dec 17, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    I am createing a thread in my mfc application in which I am playing video using Direct Show. But when I terminate thread then I am getting memory leak problem.
    Please help me as soon as possible.
    Following is code in which I am terminating thread:
    Code:
    if(m_pEditViewMC != 0)
    	{
    		m_pEditViewMC->Stop();
    		m_PrevuBtnSate = PrevuOFF;
    		m_pEditViewMC = 0;
    	}
    	if(m_PreviewThread)
    	{
    		DWORD exitcd;
    		BOOL bThrState = GetExitCodeThread(m_PreviewThread->m_hThread, &exitcd);
    		if(bThrState && (exitcd == STILL_ACTIVE))
    		{
    			TerminateThread(m_PreviewThread->m_hThread, 0);
    			delete m_PreviewThread;
    			m_PreviewThread = 0;
    		}
    	}
    	CleanVMR9();
    	/*m_btnStopPreview.EnableWindow(false);
    	m_btnPlayPreview.EnableWindow(true);*/
    	if(!m_bDeavtivateOnce){
    		ToggleStartStop(true);
    	}
    	else
    		m_bDeavtivateOnce = !m_bDeavtivateOnce;
    	this->SetFocus();
    
    Thanks and Regards,
    Sukhraj Singh
     

Share This Page