RunL in CActive derived class in not called and App exit with E32User-CBASE 46 error

Login to reply to this topic.
Thu, 2007-10-25 03:56
Joined: 2007-10-17
Forum posts: 10

Hi,

i just started working on CActive class.
created a class derived from CActive. this is sample app(without activating any view) which just display msg "Runl" when RunL is called.But
Runl is not called and app exiting with E32USER -CBASE 46 error.
My App is as follows.....

void CMYAppUi::ConstructL()
{
BaseConstructL();
if(!iMyActive)
{
iMyActive=new (ELeave) iMyActive; // allocate
iMyActive->ConstructL();
}
}
///////// MyActive derived class////////////
CMyActive::~CMyActive()
{
if(IsActive())
{
Cancel();
}
}

CMyActive::CMyActive():CActive(EPriorityHigh)
{

}

void CMyActive::ConstructL()
{
CActiveScheduler::Add(this);
SetActive();
}

void CMyActive::RunL()
{
CEikonEnv::Static()->InfoWinL(_L("Runl "),_L(" "));
}

void CMyActive::DoCancel()
{

}

//// MyActive.h

class CMyActive : public CActive
{
public:
CMyActive ();
~CMyActive ();
void ConstructL();
void RunL();
void DoCancel() ;
}

Can any one help me out in this regard.. very urgent.
thanks in advance.


Thu, 2007-10-25 05:00
Joined: 2007-08-02
Forum posts: 26
Re: RunL in CActive derived class in not called and App exit wit

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 Smiling.

Thu, 2007-10-25 05:28
Joined: 2007-10-17
Forum posts: 10
Re: RunL of Cactive not called exit with E32USER CBase 46

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

Thu, 2007-10-25 08:30
Joined: 2005-08-11
Forum posts: 278
Re: RunL in CActive derived class in not called and App exit wit

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

Thu, 2007-10-25 06:46
Joined: 2007-10-17
Forum posts: 10
Re: RunL in CActive not called exit with E32User-CBASE 46

hi max_i,

thankx for ur reply...

i tried but the same case i faced before Sad
runl not being called and app exit e32user cbase 46 error

Thu, 2007-10-25 07:18
Joined: 2005-08-11
Forum posts: 278
Re: RunL in CActive derived class in not called and App exit wit

Hi Helpplz,

Deleting AO without cancelling request usually causes the error.."e32user cbase 46"
can u post your code?

Max_i

Thu, 2007-10-25 07:35
Joined: 2007-10-17
Forum posts: 10
Re: RunL in CActive not called exit with E32User-CBASE 46 error

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;
}

Thu, 2007-10-25 07:47
Joined: 2007-09-19
Forum posts: 71
Re: RunL in CActive derived class in not called and App exit wit

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 Smiling

ohpe this small thing helps you.
however i suugest to read a bit more about AO..
and then jump tp code ..
Regards,
Sohil

Thu, 2007-10-25 08:07
Joined: 2005-08-11
Forum posts: 278
Re: RunL in CActive derived class in not called and App exit wit

Hi helppls,

have a look at this pdf file:

http://www.symbianresources.com/tutorials/advanced/activeobjects/ActiveObjects.pdf

Regards,
max_i

Thu, 2007-10-25 08:24
Joined: 2007-08-31
Forum posts: 10
Re: RunL in CActive derived class in not called and App exit wit

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

Thu, 2007-10-25 09:00
Joined: 2007-10-17
Forum posts: 10
Re: RunL in CActive not called and E32User-CBASE 46 error

Hi Swap,max_i,sohil

thanks alot to all for ur help Smiling

its working now by removing the decalration of istatus and cancelling the timer in destructor
thx for ur pdf max_i

once agan thx

Thu, 2007-10-25 09:19
Joined: 2007-09-23
Forum posts: 159
Re: RunL in CActive derived class in not called

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

Thu, 2007-10-25 10:07
Joined: 2007-10-17
Forum posts: 10
Re: RunL in CActive not called and E32User-CBASE 46 error

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.

Thu, 2007-10-25 11:20
Joined: 2005-08-11
Forum posts: 278
Re: RunL in CActive derived class in not called and App exit wit
Thu, 2007-10-25 12:57
Joined: 2007-09-23
Forum posts: 159
Re: RunL in CActive derived class in not called

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());

  • Login to reply to this topic.