Implementing NotifyProgramEnd

Before exiting completely, the debug engine must send the program destroy event (as represented by the IDebugProgramDestroyEvent2 interface) to the session debug manager and “unpublish” the program node originally published with the process debug manager (as represented by the IDebugProgramPublisher2 interface).

In TextInterpreter, these two steps are implemented in the CProgram::NotifyProgramEnd method.

To implement NotifyProgramEnd

  1. In Class View, right-click the CProgram class and click Add Function to add a function with the Function name NotifyProgramEnd, a Return type of void, an Access type of public, and no parameters; then click Finish.

  2. Open the Program.cpp file, find CProgram::NotifyProgramEnd, and add the following to it:

    void CProgram::NotifyProgramEnd(void)
    {
        CProgramDestroyEvent *pProgramDestroy = new CProgramDestroyEvent(0); 
        pProgramDestroy->SendEvent(m_spCallback, m_spEngine, this, NULL); 
    
        if (m_srpProgramPublisher != NULL) 
        { 
            m_srpProgramPublisher-> 
                UnpublishProgramNode(static_cast<IDebugProgramNode2*>(this)); 
            m_srpProgramPublisher.Release(); 
        }
    }
    
  3. In Program.cpp, find CProgram::Go and add the following to the end of that method:

            return;
        }
        NotifyProgramEnd(); 
    
  4. Build the project to make sure there are no errors.

See Also

Concepts

Terminating the Text Interpreter