本文介绍了当我关闭exe时,它的状态不会从任务管理器中删除.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

M每当我运行我的应用程序时,它都可以正常工作,但是当我用gui上的关闭按钮终止它时,它的实例将连续出现在任务管理器中.
我必须手动终止它.
M为关闭按钮提供代码.

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);
}



任何人都可以提出解决方案的建议.


问候
Ramkrishna



Can anybody suggest solution for it.


Regards
Ramkrishna

推荐答案


ramkrishna.jangale写道:
ramkrishna.jangale wrote:

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

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



删除CDialog::OnClose()PostQuitMessage(0);

而是调用CDialog::OnCancel()来关闭基于对话框的应用程序.

另一位发帖人提到,某些工作线程可能正在运行,从而使应用程序保持活动状态.错了这样的事情在本地语言程序(如C ++)中永远不可能发生.当主线程停止运行时,所有其他线程都会突然终止.



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.



这篇关于当我关闭exe时,它的状态不会从任务管理器中删除.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 23:02