activetimer.cpp

来自「symbianOS第三版开发与实用教程部分源码和部分试验」· C++ 代码 · 共 65 行

CPP
65
字号
// Copyright (c) 2006 Nokia Corporation.

#include "ActiveTimer.h"
#include "ActiveTimerNotify.h"


// Constructs a CActiveTimer object
CActiveTimer* CActiveTimer::NewL(MActiveTimerNotify& aNotifier)
    {
    CActiveTimer* self = new (ELeave) CActiveTimer(aNotifier);
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop();
    return self;
    }


// C++ Destructor
CActiveTimer::~CActiveTimer()
    {
	Cancel();
    iTimer.Close();
    }


// Initiates the asynchronous timer request and sets the active object
// ready to handle its completion
void CActiveTimer::After(TTimeIntervalMicroSeconds32 anInterval)
    {
    iTimer.After(iStatus, anInterval);
    SetActive();
    }


// Handles the completion of the asynchronous timer request
void CActiveTimer::RunL()
    {
    iNotifier.TimerComplete(iStatus.Int());
    }


// Handles the cleanup necessary if the 
// asynchronous timer request is cancelled
void CActiveTimer::DoCancel()
    {
    iTimer.Cancel();
    }


// C++ constructor
CActiveTimer::CActiveTimer(MActiveTimerNotify& aNotifier) : 
    CActive(EPriorityStandard),
    iNotifier(aNotifier)
    {
    CActiveScheduler::Add(this);
    }


// Second-phase constructor
void CActiveTimer::ConstructL()
    {
    User::LeaveIfError(iTimer.CreateLocal());
    }

// End of file

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?