![]() |
PeriodicThread() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Private Function |
Declared in: PeriodicThread.h |
Declaration
static DWORD PeriodicThread(
LPVOID lpData);
DescriptionOur thread proc
Function Body
try
{
//Get our class
CPeriodicThread* pClass;
pClass=(CPeriodicThread*)lpData;
//Do we exit
BOOL bExit;
bExit=FALSE;
//Run user proc
try
{
if (!(*pClass->m_pUserProc)(tsStart,
pClass->m_lpData))
//We are aborting
bExit=TRUE;
}
catch (...)
{
bExit=TRUE;
}
//Do we exit
if (bExit)
pClass->m_bAbort=TRUE;
//Set we are alive
if (pClass->m_pEnterEvent)
pClass->m_pEnterEvent->Set();
else
return FALSE;
//Do we exit
if (bExit)
return FALSE;
//Is it the first run ?
BOOL bFirstRun;
bFirstRun=TRUE;
//Run
while (1)
{
//Do we have a valid interval ?
if (!pClass->m_dwInterval)
{
//Report it
ReportStaticError(CPeriodicThread_Class,"PeriodicThread","Zero interval!");
//Exit
break;
}
//Is it first run ?
if (bFirstRun)
//Not anymore
bFirstRun=FALSE;
else
//Wait for the timeout
if (!pClass->m_pExitEvent->Wait(pClass->m_dwInterval))
break;
//Run user proc
try
{
if (!(*pClass->m_pUserProc)(tsBody,
pClass->m_lpData))
//We are aborting
bExit=TRUE;
}
catch (...)
{
bExit=TRUE;
}
//Do we exit
if (bExit)
{
//Abort it
pClass->m_bAbort=TRUE;
//Exit
return FALSE;
}
}
//Exit value
BOOL bValue;
//Call user proc again
try
{
bValue=(*pClass->m_pUserProc)(tsEnd,
pClass->m_lpData);
}
catch (...)
{
bValue=FALSE;
}
//Set the exit event
pClass->m_pEnterEvent->Set();
//Exit
return bValue;
}
ERROR_HANDLER_STATIC_RETURN(CPeriodicThread_Class,"PeriodicThread",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. |