Click here to Skip to main content
15,905,612 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
M Whenever i run my application it works fine but when i terminate it with close button on gui then its instance continuously present in task manager.
I have to manually terminate it .
M giving code for close button.
void CFace_RecognitionDlg::OnBnClickedClose()  // Close the dialog box 
{
    if(dbNames)                  //Deallocating the array of CString
    {
        delete [] dbNames;
        dbNames = NULL;
    }
    KillTimer(TIMER_STREAM_PREVIEW);    //Timer to preview 
                                        //the camera stream on dialog 
                                        //killing that preview timer.

    //Deinitialize Web Camera interface.
    capCaptureStop(hWndC);
    capDriverDisconnect(hWndC);
    hWndC=NULL;
    
    m_hBmp=NULL;
    dcMem.Detach();
    //Update UI accordingly
    UpdateData(false);
    InvalidateRect(m_rectFrame);
    OnPaint();
    CDialog::OnClose();
    PostQuitMessage(0);
}


Can anybody suggest solution for it.


Regards
Ramkrishna
Posted
Updated 21-Jan-10 21:20pm
v2

When your application doesn't terminate, you should look in the CWinApp part of your project, e.g. InitInstance() and ExitInstance().
 
Share this answer
 
ramkrishna.jangale wrote:
CDialog::OnClose();
PostQuitMessage(0);


Remove CDialog::OnClose() and PostQuitMessage(0);

Call CDialog::OnCancel() instead to shut down a dialog based application.

Another poster mentioned that some worker thread may be running, keeping the app alive. That's wrong. Such a thing can can never happen in a native language program (like C++). When the main thread comes to a halt, every other thread will be killed abruptly.
 
Share this answer
 
Are you using any threads other than the UI thread in this app?

If yes those other thread(s) might still be running and keeping the application open.

Hope this helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900