Class CSocketThreadManager::
CleanThreads()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: m_ulThreadCountNext page: CSocketThreadManager    Show member index
Private Function Declared in:
SocketThreadManager.h

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

void CleanThreads(
    BOOL bError);

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

Delete the thread structure

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

try
{
    //Our wait list
    CWaitList aList;

    //Start deleting
    if (m_pThreadData)
    {
        //Our counter
        int iCounter;

        //Delete the threads
        for (iCounter=0;iCounter<m_ulThreadCount;++iCounter)
            //Post a stop message
            if (m_pThreadData[iCounter].pThread->GetThreadID())
            {
                //Send the message
                PostThreadMessage(m_pThreadData[iCounter].pThread->GetThreadID(),WM_QUIT,0,0);

                //Are we nice or not ?
                if (bError)
                    //Delete the window
                    DestroyWindow(m_pThreadData[iCounter].hWindowHandle);
                else if (m_pThreadData[iCounter].pEvent)
                    aList.AddObject(m_pThreadData[iCounter].pEvent,TRUE);
            }

        //Error or not ?
        if (bError)
            //Sleep to allow the threads to quit
            Sleep(1000);
        else
        {
            //Tmp object
            DWORD dwTmp;

            //Wait for threads
            if (aList.Wait(TRUE,dwTmp,THREADS_TIMEOUT))
                ReportError("CleanThreads","Timeout waiting for threads!");
        }

        //Delete the thread classes
        for (iCounter=0;iCounter<m_ulThreadCount;++iCounter)
        {
            //And delete the thread
            delete m_pThreadData[iCounter].pThread;

            //Delete the CS
            delete m_pThreadData[iCounter].pCSection;

            //Delete the event
            delete m_pThreadData[iCounter].pEvent;

            //Are we nice or not ?
            if (!bError)
                //Delete the window
                DestroyWindow(m_pThreadData[iCounter].hWindowHandle);
        }

        //Delete the structure
        delete [] m_pThreadData;
    }
}
ERROR_HANDLER("CleanThreads")

'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.