??
字號:
我自己寫了個控制臺的程序 有個活動對象ActiveObjectClass,在控制臺中主程序中我啟動了活動對象,
描述如下:
ActiveObjectClass* obj= ActiveObjectClass::NewL();//已經(jīng)把活動對象添加到規(guī)化器中
obj->StartL(10000);//啟動活動對象
while(true)//因為我的活動對象會在控制臺上會打印信息所以弄了個死循環(huán)
{
;
}
問題:我在Runl()中有輸出信息的代碼,運(yùn)行時候為什么控制臺上沒有反應(yīng)?(應(yīng)該是沒有執(zhí)行)
本來我是準(zhǔn)備懸分的,但是囊中實在太羞澀,不好意思....... 那位高手幫忙解釋下,困惑中.....
你的StartL(10000)是怎么樣implemented?
其實只要有做到 以下幾點,那應(yīng)該沒有問題
1。 CActiveScheduler::Add(this)
2. 發(fā)出需求,比如: RFile::Read(TInt aPos,TDes8& aDes,TRequestStatus& aStatus);
3. SetActive()
還 有 什 么 問 題 么 ?
對你提出的條件我都滿足了:
1. CActiveScheduler::Add(this) 在ActiveObjectClass* obj= ActiveObjectClass::NewL里面包含(有問題嗎?)
2. 發(fā)出需求:
StartL()
{
Cancel(); // Cancel any request, just to be sure
iState = EUninitialized;
iTimer.After(iStatus, aDelay); // Set for later
SetActive(); // Tell scheduler a request is active
//User::WaitForRequest(iStatus);(這句話必須嗎?)
}
3 .StartL()已經(jīng)SetActive了
、、、、、、、、、、、、、、、、、、、、、、、、
CPrintInfor::CPrintInfor() :
CActive(EPriorityStandard)
{
}
CPrintInfor* CPrintInfor::NewLC()
{
CPrintInfor* self = new ( ELeave ) CPrintInfor();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CPrintInfor* CPrintInfor::NewL()
{
CPrintInfor* self = CPrintInfor::NewLC();
CleanupStack::Pop(); // self;
return self;
}
void CPrintInfor::ConstructL()
{
User::LeaveIfError(iTimer.CreateLocal() ); // Initialize timer
iConsole = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,
KConsFullScreen));
iConsole->Write(_L("Console Created...!\n"));
CActiveScheduler::Add( this); // Add to scheduler
iConsole->Write(_L("Add to CActiveScheduler...!\n"));
}
void CPrintInfor::StartL(TTimeIntervalMicroSeconds32 aDelay)
{
Cancel(); // Cancel any request, just to be sure
iState = EUninitialized;
iTimer.After(iStatus, aDelay); // Set for later
SetActive(); // Tell scheduler a request is active
//User::WaitForRequest(iStatus);
}
void CPrintInfor::RunL()
{
if (iState == EUninitialized)
{
iState = EInitialized;
iConsole->Write(_L("EUninitialized...!\n"));
}
else
if (iState != EError)
{
iConsole->Write(_L("EError...!\n"));
}
SetActive(); // Tell scheduler a request is active
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -