📄 exampletimer.cpp
字号:
#include "ExampleTimer.h"
// Constructs a CExampleTimer object
CExampleTimer* CExampleTimer::NewL(MExampleTimerNotify& aNotifier)
{
CExampleTimer* self = new (ELeave) CExampleTimer(aNotifier);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop();
return self;
}
// C++ Destructor
CExampleTimer::~CExampleTimer()
{
Cancel();
iTimer.Close();
}
// Initiates the asynchronous timer request and sets the active object
// ready to handle its completion
void CExampleTimer::After(TTimeIntervalMicroSeconds32 anInterval)
{
if(!IsActive())
{
iTimer.After(iStatus, anInterval);
SetActive();
}
}
// Handles the completion of the asynchronous timer request
void CExampleTimer::RunL()
{
iNotifier.TimerExpired(iStatus.Int());
}
// Handles the cleanup necessary if the
// asynchronous timer request is cancelled
void CExampleTimer::DoCancel()
{
iTimer.Cancel();
}
// C++ constructor
CExampleTimer::CExampleTimer(MExampleTimerNotify& aNotifier) :
CActive(EPriorityStandard),
iNotifier(aNotifier)
{
CActiveScheduler::Add(this);
}
// Second-phase constructor
void CExampleTimer::ConstructL()
{
User::LeaveIfError(iTimer.CreateLocal());
}
// End of file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -