Symbian 活动规划器 CActiveScheduler 的灵活应用
2010-03-26 21:23:00 来源:WEB开发网// the active scheduler to panic.
TInt RunError(TInt aError);
public:
enum TNewClassTestState
{
EUninitialized=12, // Uninitialized
EInitialized=22, // Initalized
EError=32 // Error condition
};
private:
TInt iState; // State of the active object
RTimer iTimer; // Provides async timing service
};
#endif // NEWCLASSTEST_H
/* ============================================================================
Name : NewClassTest.cpp Author : Alex Version : 1.0 Copyright : su-fun Description : CNewClassTest implementation ============================================================================ */
#include "NewClassTest.h"
CNewClassTest::CNewClassTest() : CActive(EPriorityStandard) // Standard priority
{
}
CNewClassTest* CNewClassTest::NewLC()
{
CNewClassTest* self = new ( ELeave ) CNewClassTest();
CleanupStack::PushL(self);
self->ConstructL(); return self;
}
CNewClassTest* CNewClassTest::NewL()
{
CNewClassTest* self = CNewClassTest::NewLC();
CleanupStack::Pop(); // self;
return self;
}
void CNewClassTest::ConstructL()
{
User::LeaveIfError(iTimer.CreateLocal() ); // Initialize timer
CActiveScheduler::Add( this); // Add to scheduler
}
CNewClassTest::~CNewClassTest()
{
Cancel(); // Cancel any request, if outstanding
iTimer.Close(); // Destroy the RTimer object
// Delete instance variables if any
}
void CNewClassTest::DoCancel()
{
iTimer.Cancel();
}
void CNewClassTest::StartL(TInt aState, TTimeIntervalMicroSeconds32
更多精彩
赞助商链接