У меня есть класс, производный от класса CTimer.У меня есть экземпляр RThread в качестве члена данных, чтобы периодически вызывать метод CTimer :: After ().Код:
void CTimerThread::RunL()
{
qDebug() << "Value=" << ++iCounter;
if (iThread->ExitType() == EExitKill)
{
if (KErrNone == CreateThread())
iThread->Resume();
}
}
void CTimerThread::StartL()
{
qDebug() << "In the StartL( );";
if(isThreadCreated == EFalse)
User::LeaveIfError(CreateThread ());
iThread->Resume();
}
TInt CTimerThread::ThreadFunction(TAny *sender)
{
CTrapCleanup* cleanupStack = CTrapCleanup::New();
CTimerThread* host = (CTimerThread*)sender;
forever {
host->After(host->iInterval->Int());
if (!host->isSchedulStarted)
{
CActiveScheduler::Start();
host->isSchedulStarted = ETrue;
}
}
delete cleanupStack;
return 1;
}
TInt CTimerThread::CreateThread()
{
TInt err = KErrNone;
_LIT(KNameBase, "Thread_");
TBuf<10> name(KNameBase);
name.AppendNum(iCounter);
err = iThread->Create(name, CTimerThread::ThreadFunction, 4096, NULL, this);
if( err == KErrNone)
isThreadCreated = ETrue;
return err;
}
Когда я выполняю StartL (), я всегда получаю , исключение прерывания данных происходит .в чем проблема?