![]() |
Start() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Public Function |
Declared in: PeriodicThread.h |
Declaration
BOOL Start(
DWORD dwInterval,
LPVOID lpData);
DescriptionStart the thread dwInterval - Interval to run the thread at (MS) lpData - Custome user data to pass to the thread
Function Body
try
{
//Is the interval legal
if (!dwInterval)
{
//Report it
ReportError("Start","Invalid interval!");
//Exit
return FALSE;
}
//Are we running
if (m_dwInterval ||
m_pEnterEvent ||
m_pExitEvent)
{
//Report it
ReportError("Start","Already running!");
//Exit
return FALSE;
}
//We are not aborting
m_bAbort=FALSE;
//Create all
m_pEnterEvent=COSManager::CreateEvent();
m_pExitEvent=COSManager::CreateEvent();
//Save the user data
m_lpData=lpData;
//Save the interval
m_dwInterval=dwInterval;
//Set it to auto delete
m_pThread->SetAutoDelete(TRUE);
//Run the thread
m_pThread->Start((LPVOID)this);
//Wait for the event
if (m_pEnterEvent->Wait(m_dwThreadTimeout) ||
m_bAbort)
{
//Report it
if (m_bAbort)
ReportError("Start","User aborted!");
else
ReportError("Start","Timeout waiting for thread!");
//Delete it all
delete m_pThread;
m_pThread=COSManager::CreateThread(PeriodicThread);
//The events
delete m_pEnterEvent;
m_pEnterEvent=NULL;
delete m_pExitEvent;
m_pExitEvent=NULL;
//Exit
return FALSE;
}
else
return TRUE;
}
ERROR_HANDLER_RETURN("Start",FALSE)
See Also
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. |