RunL in CActive derived class in not called and App exit with E32User-CBASE 46 error
| Thu, 2007-10-25 03:56 | |
|
Hi, i just started working on CActive class. void CMYAppUi::ConstructL() CMyActive::CMyActive():CActive(EPriorityHigh) void CMyActive::ConstructL() void CMyActive::RunL() void CMyActive::DoCancel() //// MyActive.h class CMyActive : public CActive Can any one help me out in this regard.. very urgent. |
|






Forum posts: 26
from the code i cannot understand what is ur purpose but one wrong thing i can see is in ur ConstructL method ur calling setactive without setting the iStatus to KRequestPending.
.
First do that and check .Hope it helps
Forum posts: 10
hi Prajwal,
i just want to see when the runl be called just with sample code.
isn't that Runl called after setactive()?
hey i set istatus to KRequestPending but still iam getting the same error..
Actaually i need to implaement an application which continuously runs at background and get data from http url for every time interval and show to user and again need to run at background.
as i understood from formus for app to run at background we need to have a class derived from CActive... so i just wrote a mock application as i posted above to know when Runl can be called...
thanks
Forum posts: 278
Hi helpplz,
Where have u set your istatus ???
Here's an example:
class CMyActive : public CActive
{
public:
CMyActive ();
~CMyActive ();
void ConstructL();
void RunL();
void DoCancel() ;
IssueRequest();
RTimer iTimer;
}
void CMyActive::ConstructL()
{
CActiveScheduler::Add(this);
}
void CMyActive::IssueRequest()
{
timer.CreateLocal();
timer.After(iStatus,5000000); // waits for 5 seconds and runs RunL
SetActive();
}
void RunL()
{
EikonEnv::Static()->InfoWinL(_L("Runl "),_L(" "));
}
call
ConstructL() then
IssueRequest() -> after 5 seconds ur RunL() will be called!
max_i
Forum posts: 10
hi max_i,
thankx for ur reply...
i tried but the same case i faced before
runl not being called and app exit e32user cbase 46 error
Forum posts: 278
Hi Helpplz,
Deleting AO without cancelling request usually causes the error.."e32user cbase 46"
can u post your code?
Max_i
Forum posts: 10
hi,
i Actually taken helloworld basic exampl commented the activation of view
below is my code,
void CMYAppUi::ConstructL()
{
BaseConstructL();
if(!iMyActive)
{
iMyActive=new (ELeave) iMyActive; // allocate
iMyActive->ConstructL();
iMyActive->Request();
}
///i commented activating the view... this is basically the hellowworldbasic example from 3rd editin sdk
}
CMYAppUi::~CMYAppUi()
{
if ( iAppView )
{
delete iAppView;
iAppView = NULL;
}
delete iMyActive;
}
class CMyAppUi: public CAknAppUi
{
public: // Constructors and destructor
void ConstructL();
///some basic functions,
CMyActive* iMyActive;
}
///////// MyActive derived class////////////
CMyActive::~CMyActive()
{
if(IsActive())
{
Cancel();
}
}
CMyActive::CMyActive():CActive(EPriorityHigh)
{
}
void CMyActive::ConstructL()
{
CActiveScheduler::Add(this);
}
void CMyActive::RunL()
{
CEikonEnv::Static()->InfoWinL(_L("Runl "),_L(" "));
}
void CMyActive::Request()
{
timer.CreateLocal();
timer.After(iStatus,5000000);
SetActive();
}
void CMyActive::DoCancel()
{
}
//// MyActive.h
class CMyActive : public CActive
{
public:
CMyActive ();
~CMyActive ();
void ConstructL();
void RunL();
void DoCancel() ;
void Request();
RTimer timer;
TRequestStatus iStatus;
}
Forum posts: 71
First of all you do not need to set the iStatus value..
I think you need read a bit more about active object..
Also the RunL is called if you say setactive however setactive is to be call after giving a ascyn call to a function...
or give the Timer and call setactive.. to make you above active object work
let help you out calling RunL using a timer
create a variable in you ao class called
RTimer iTimer;
in you constructL class just add the ao to the active scheduler..
call the function pqr which is a part of active object class and out in the following line..
function pqr
User::LeaveIfError(iTimer.CreateLocal());
iTimer.After(iStatus,iInterval);
SetActive();
once you make a asyn call then after you call is serviced then the runl gets called ti doesnt get called immediately when you call set active
ohpe this small thing helps you.
however i suugest to read a bit more about AO..
and then jump tp code ..
Regards,
Sohil
Forum posts: 278
Hi helppls,
have a look at this pdf file:
http://www.symbianresources.com/tutorials/advanced/activeobjects/ActiveObjects.pdf
Regards,
max_i
Forum posts: 10
Hi ,
You should not declare the
TRequestStatus iStatus;
in u r CActive derived class , its already the public member of the CActive class .
Due to which CActive object is not able to verify iStatus is chaged to call RunL function .
I would like to suggest its good practise to implement RunError( ) function also.
Regards
Forum posts: 10
Hi Swap,max_i,sohil
thanks alot to all for ur help
its working now by removing the decalration of istatus and cancelling the timer in destructor
thx for ur pdf max_i
once agan thx
Forum posts: 159
Can we get a few things clear here - you should not set your iStatus to TRequestPending or anything else and you shouldn't declare an additional TRequestStatus (why on earth do so many of you do this all the time? )
Everybody please read:
http://www.newlc.com/topic-13580
There are several mistakes in the code posted, read the above and find them all.
P.S.
What is this meant to be:
iMyActive=new (ELeave) iMyActive; // allocate
Forum posts: 10
hi numpty,
thanks for the like which helps as alot...
i used iMyActive=new (ELeave) iMyActive for custructing a new object... if tere is any wrong help help me so that will not repeat this..is it that push n pop to cleanupstack?
thanks.
Forum posts: 278
No that is not a push or a pop to/from the cleanup stack.
For push and pop to/from the cleanup stack
Have a look at these links:
http://www.symbian.com/developer/techlib/v70sdocs/doc_source/devguides/cpp/Base/MemoryManagement/CleanupSupport/CleanupSupportGuide3/HowToCBase.guide.html
http://newlc.com/Simplify-Two-Phase-Constructor-in.html
Forum posts: 159
I don't understand how that line compiles is what I meant.
Shouldn't it be something like:
iMyActive=new (ELeave) CMyActive;
(or iMyActive = CMyActive::NewL());