Class CManagedThread::
Stop()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: StartNext page: Custom Code in Header Before Includes    Show member index
Public Function Declared in:
ManagedThread.h

'Declaration' icon -- Shortcut to top of page. Declaration

BOOL Stop();

'Description' icon -- Shortcut to top of page. Description

Stop the thread

'Function Body' icon -- Shortcut to top of page. Function Body

try
{
    if (m_bDestructor)
        if (!m_pEnterEvent ||
            !m_pExitEvent)
        {
            //Just delete the thread
            delete m_pThread;

            //Exit
            return TRUE;
        }
        else
            ;
    else
        //Are we running
        if (!m_pEnterEvent ||
            !m_pExitEvent)
        {
            //Report it
            ReportError("Stop","Not running!");

            //Exit
            return FALSE;
        }

    //The thread ID
    DWORD dwThreadID;
    dwThreadID=m_pThread->GetThreadID();

    //Call the thread
    m_pExitEvent->Set();

    //Wait for the thread
    if (GetCurrentThreadId()!=dwThreadID &&
        m_pEnterEvent->Wait(m_dwThreadTimeout))
    {
        //Report it
        ReportError("Stop","Timeout waiting for thread!");

        //Delete it by force
        delete m_pThread;
    }

    //Delete it all
    m_pThread=NULL;

    //Do we need to recreate
    if (!m_bDestructor)
        m_pThread=COSManager::CreateThread(ManagedThread);

    //The events
    delete m_pEnterEvent;
    m_pEnterEvent=NULL;

    delete m_pExitEvent;
    m_pExitEvent=NULL;

    //Done
    return TRUE;
}
ERROR_HANDLER_RETURN("Stop",FALSE)

'See Also' icon -- Shortcut to top of page. See Also

Class Overview Class Overview  |  Public base class CErrorHandler  |  Hierarchy Chart Hierarchy Chart


Get Surveyor!This web site was generated using Surveyor V4.50.811.1.  Click here for more information. Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003.