Problem with CActiveScheduler::Add(this)....

Login to reply to this topic.
Fri, 2006-04-21 09:18
Joined: 2006-04-08
Forum posts: 41
Hi ,
Now i am using debugger n i have find that my program is creashing when i issue 'CActivescheduler::Add(this)' , at this point it gets crashed.
i also want to tell u that i am not starting or doing anything to CActiveScheduler class prior to adding this object on scheduler.
Do i need to install n then start my active scheduler bcoz i am assuming that in the deafult thread of any process, active scheduler is already present n it need not to start.Am i doing Right ir not?HuhHuh

n one thing more i am gettign the following msg in epocwind.oout:
Can't load phbksyncsvr.dll


Plz Respond immediately.
Thanx,
Amit.

Fri, 2006-04-21 10:31
Joined: 2004-05-24
Forum posts: 982
Re: Problem with CActiveScheduler::Add(this)....
And the error is? Have you read the sdk...Add can generate 3 panics but all of them are more than explicit

pirosl

Fri, 2006-04-21 11:04
Joined: 2003-12-05
Forum posts: 683
Re: Problem with CActiveScheduler::Add(this)....
If your app is a GUI app, the scheduler is there. Just Add your AO to the scheduler. Usually this happens in the end of AO's ConstructL (if it has one).

Would be nice to see some code -- without it we all can just guess...
Fri, 2006-04-21 11:35
Joined: 2004-11-29
Forum posts: 1246
Re: Problem with CActiveScheduler::Add(this)....
Its not present in the default thread of any process, only in gui applications.

And please do not write stuff like "Plz respond immediatly". Its rude.
The people here are not paid to answer your questions, its something we do on our own time, because we like to contribute to the developer community. If it is a sensibly written question, and someone knows the answer, you will get a quick response anyway.

If you don't, its either because noone here knows the answer, or noone understands what it is you are asking about.
Fri, 2006-04-21 11:48
Joined: 2004-05-24
Forum posts: 982
Re: Problem with CActiveScheduler::Add(this)....
+1 to alh Smiley

pirosl

Fri, 2006-04-21 13:07
Joined: 2006-04-08
Forum posts: 41
Re: Problem with CActiveScheduler::Add(this)....
ok alh, i got ur point . don't mind, i know that u r not being paid for it.
As far as my problem is concerened, i am implementing a dll not a GUI application.
N now i have created a now active scheduler in it, install it n when i issue Start() for it, then thread got hanged, is it waiting for some RunL() to hit...Huh?
if yes then it means that i will have to wait there for some RunL() to be hitted.
Bcoz i was assuming that this active scheduler will behave normally as of any GUI application's active scheuler where we keep on adding active objects to the scheduler without caring to start it or anything else... now can any body tell me what is the behaviour of active scheduler which we install on our own..Huh?
Thanx & Regards,
Amit.
Fri, 2006-04-21 13:22
Joined: 2004-05-24
Forum posts: 982
Re: Problem with CActiveScheduler::Add(this)....
There is "one" behaviour for active scheduler...doesn't matter if you are in ui application or dll.What do you mean by "some RunL() to hit....". The RunL method will be invoked when the request is complete....

pirosl

Fri, 2006-04-21 13:36
Joined: 2006-04-08
Forum posts: 41
Re: Problem with CActiveScheduler::Add(this)....
Quote from: pirosl
There is "one" behaviour for active scheduler...doesn't matter if you are in ui application or dll.What do you mean by "some RunL() to hit....". The RunL method will be invoked when the request is complete....
what i have observed through debugger in my program is that when my line of code in my dll
'CActiveScheduler::Start()' is encountered then the thread got hang up....
i am giving some piece of my code below:

void SocketManager::ConstructL()
{
   //Creating, installing and starting Active scheduler for itself.

   iCurrentScheduler=new (ELeave) CActiveScheduler();
   CActiveScheduler::Install(iCurrentScheduler);

   //Here after executing instruction below thread is hanging up.
                CActiveScheduler::Start();

   iResolver=CHostResolver::NewL(this,iSocketServerSession);
}

Above ConstructL() is just called from the constructor of one class inmy static dll whose APIs my application will use.

Thanx,
Amit.
Fri, 2006-04-21 14:08
Joined: 2004-05-24
Forum posts: 982
Re: Problem with CActiveScheduler::Add(this)....
You must add at least one active object to active scheduler before start it.

From sdk:
"At least one active object, with an outstanding request, must be added to the scheduler before the wait loop is started, otherwise no events will occur and the thread will hang, or any events that do occur will be counted as stray signals, raising a panic."


pirosl

Fri, 2006-04-21 14:36
Joined: 2006-04-08
Forum posts: 41
Re: Problem with CActiveScheduler::Add(this)....
Quote from: pirosl
You must add at least one active object to active scheduler before start it.

From sdk:
"At least one active object, with an outstanding request, must be added to the scheduler before the wait loop is started, otherwise no events will occur and the thread will hang, or any events that do occur will be counted as stray signals, raising a panic."


See i am developing a socket manager dll which an application will use, now in the start i am just creating socketmanager class's instance which will do the following things:
1)it will just create open a session with socket server.
2)it will create instance of another class which socket manager will use for resolving remote domain namesn it is also an active object, i have added in that active scheduler.
3)it will also create reader n writer active objects which i have also added on active scheduler.
thats is all for its creation.

Now if appliation will call my API of this socketmanager class to 'ReadFromSocketAsynchronously()', what do u suggest that should i Start() active scheduler from within this API....Huh? If yes, then what, if application again call this API for some another socket, it will again issue Start() for active scheduler....Huh will it not result in nested Start loops..Huh
Can u suggest me a solution to cop up with this problem???
Thanx & Regards,
Amit. 
Fri, 2006-04-21 14:45
Joined: 2004-05-24
Forum posts: 982
Re: Problem with CActiveScheduler::Add(this)....
If i understood corectly your problem...you can start the activescheduler only when the first active object is added....but...there is a big but....you can't be sure that the first active object will have an outstanding request (since it comes from client app as i understood)....

The best thing in your case is to add a fake active object to your active scheduler (in the code you presented to us) you'll add an ao which will outstand time requests for example.....in this case you're sure at least one ao with an outstanding request is in your active scheduler....and even if the client will not add any ao the app will still run...

Does this make any sense for you?

pirosl

Fri, 2006-04-21 15:20
Joined: 2006-04-08
Forum posts: 41
Re: Problem with CActiveScheduler::Add(this)....
Quote from: pirosl
If i understood corectly your problem...you can start the activescheduler only when the first active object is added....but...there is a big but....you can't be sure that the first active object will have an outstanding request (since it comes from client app as i understood)....

The best thing in your case is to add a fake active object to your active scheduler (in the code you presented to us) you'll add an ao which will outstand time requests for example.....in this case you're sure at least one ao with an outstanding request is in your active scheduler....and even if the client will not add any ao the app will still run...

Does this make any sense for you?
Thanx buddy,u have got my problem rightly.
 i am getting ur point but i am not getting u completely.
bcoz what that fake active object will do..Huh
n when i wll issue start() for that fake ao then will it not be my thread be waiting for some RunL() of that fake ao or any other ao(if there is) to hit..Huh
Can u plz give me a piece of code to solve this problem..Huh

Really Thanx buddy,
Amit.
 
Fri, 2006-04-21 15:23
Joined: 2004-05-24
Forum posts: 982
Re: Problem with CActiveScheduler::Add(this)....
you don't start the ao (you start the as...please dont mix the terms). From ao you'll issue an async request. When the request is complete the as will call ao's runl method. the fake ao can be for example an ao which will make request to time service provider...and for example will be  notified every 5 minutes (or what ever)....or any other kind of simple ao you want.

pirosl

Fri, 2006-04-21 19:13
Joined: 2004-05-24
Forum posts: 982
Re: Problem with CActiveScheduler::Add(this)....
Quote from: NumptyAlert

Your last post on this link is nice but unfortunatelly will not help him to understand where he missundertands Sad I think you should improve it a litle bit and write also about async requests and service providers and actually what's the whole issue regarding ao/as......but i think there is already a tutorial on this site about this, or?

pirosl

Fri, 2006-04-21 20:21
Guest (not verified)
Forum posts: 2043
Re: Problem with CActiveScheduler::Add(this)....
>> >> See i am developing a socket manager dll which an application will use

If you are creating a DLL which will be used by an app then you shouldn't be creating and starting an active scheduler within the DLL itself as when the DLL is used by the application there will be one already installed by the UI framework.

If the DLL is being used by something which isn't an app i.e. just an exe, then still you shouldn't add an active scheduler to the DLL, you should add it to the exe.

[Also there should never ever be any need to have a 'fake' active object which is making some arbitary and random request such as  a timer request. If any implementation ever has such a thing it has been incorrectly designed.]
Sat, 2006-04-22 07:14
Joined: 2006-04-08
Forum posts: 41
Re: Problem with CActiveScheduler::Add(this)....
Quote from: pirosl
you don't start the ao (you start the as...please dont mix the terms). From ao you'll issue an async request. When the request is complete the as will call ao's runl method. the fake ao can be for example an ao which will make request to time service provider...and for example will be  notified every 5 minutes (or what ever)....or any other kind of simple ao you want.
Hi,
Sorry, i was confusing little bit AS with AO, but i am clear abt it that we have to start AS (NOT AO).
But now if we look at the problem, u r suggesting me to Start() AS from within my dll n putting a fake AO on it, but don't u think in this way if i will proceed i will not be able to return the control of program to the appn(or exe) using my dll, control will hung in my Start loop, how will appn(or exe) get control back...Huh
Plz also see reply to thread created by Numpty which u have given me as link.
i have written this in detail, plz have a look at it n also plz see what Guest says at reply no 14.
Regards,
Amit.
  • Login to reply to this topic.