Hi folks.
I am attempting to create an active object that is driven by a timer. The code successfully starts the timer, processes the timeouts then restarts the timer. However if I attempt to cancel the timer emulator halts with the statement "Suspended: Signal 'Exception 5' received. Description Access Violation.". Although I have implemented a DoCancel() member, the function is not invoked.
I would be very grateful if any one can provide an explaination for this behaviour.
I am developing for S60, Symbian 8.1, Carbide 1.1.
The class is invoked with:
iTimer1 = CTimeWatch::NewL();
iTimer1->StartTimerL(10000000);
and I am attempting to cancel the timeout with
iTimer1->Cancel();
The code for the class is:
class CTimeWatch: public CActive
{
public:
static CTimeWatch * NewL(void);
~CTimeWatch (void);
void StartTimerL(TTimeIntervalMicroSeconds32& aInterval);
private:
void ConstructL(void);
CTimeWatch (void);
void RunL(void);
void DoCancel(void);
TInt RunError(TInt aError);
private:
RTimer iRTimer;
TTimeIntervalMicroSeconds32 iInterval;
};
CTimeWatch::CTimeWatch(void)
: CActive (EPriorityStandard)
{
CActiveScheduler::Add(this);
}
CTimeWatch* CTimeWatch::NewL()
{
CTimeWatch* self = new (ELeave) CTimeWatch();
self->ConstructL();
return self;
}
void CTimeWatch::ConstructL(void)
{
User::LeaveIfError (iRTimer.CreateLocal());
}
CTimeWatch::~CTimeWatch(void)
{
Cancel();
iRTimer.Close();
}
void CTimeWatch::StartTimerL(TTimeIntervalMicroSeconds32& aInterval)
{
iInterval = aInterval;
iRTimer.After (iStatus, aInterval);
SetActive();
}
void CTimeWatch::RunL()
{
iRTimer.After (iStatus, iInterval);
SetActive();
}
void CTimeWatch:oCancel()
{
iRTimer.Cancel();
}

oCancel()
Reply With Quote

