×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    6

    ActiveObject RunL is called just once

    Hello Guys,

    I know that hundred of messages about AO exists in this forums, but I can't find what I did wrong.
    My problem is that RunL is called just once. The program keep running, but the UI is not responsive any more and RunL is not called a second time.

    This is the code that completes the request, inside another thread:

    RThread control;
    DEBUG("Setting status");
    TRequestStatus * pstatus = &f->iStatus;
    control.RequestComplete(pstatus,KErrNone);
    DEBUG("Status set to KErrNone");

    I receive all debug messages, even when RunL is not called. This code runs in a RThread and I use a message queue to start and stop the thread work. The queue is working fine, but after the first call to RunL the UI stop working.

    Here is my RunL:

    void CA...::RunL() {
    DEBUG("RunL Executed");
    }

    Really just this. I log it when it has been called. The first time it works, but the UI is dead after it. The application continues to run and even to respond to key events. I call setActive in this routine:

    void CA...::Activate(){
    DEBUG("Verifing if added");
    if(IsAdded()==EFalse)
    {
    DEBUG("Not added yet, next calls will fail !!!");
    }
    else
    {
    DEBUG("Already added");
    }

    DEBUG("Verifing if active");
    if(IsActive()==EFalse) {
    DEBUG("Activating");
    iStatus=KRequestPending;
    SetActive();
    DEBUG("Activated");
    }
    else {
    DEBUG("Already active. Doing nothing.");
    }
    }

    And this is called from the Active Object:
    void CA...::restart()
    {
    TUint32 msg = 3;
    Activate();
    if(state==0)
    queue.Send(msg);
    }

    I set iStatus=KRequestPending because the thread is activated by a message, i.e. it's waiting for messages and not a method call.


    The messages are received and RunL executes fine. But the second time only the messages are received, but RunL is not executed.

    The first and second run I activate the AO give me the same sequence of Activate debug messages(as the first time):

    36.660 [DEBUG] Verifing if added
    36.660 [DEBUG] Already added
    36.660 [DEBUG] Verifing if active
    36.660 [DEBUG] Activating
    36.660 [DEBUG] Activated
    ...
    39.740 [DEBUG] Setting status
    39.740 [DEBUG] Status set to KErrNone
    ...
    39.755 [DEBUG] RunL Executed
    ...
    53.760 [DEBUG] Verifing if added
    53.760 [DEBUG] Already added
    53.760 [DEBUG] Verifing if active
    53.760 [DEBUG] Activating
    53.760 [DEBUG] Activated
    ...
    62.260 [DEBUG] Setting status
    62.260 [DEBUG] Status set to KErrNone
    ...

    But this time RunL is not called anymore.
    I copied these lines from Epoc.out. The application continues to run, except its UI is now frozen, but I still get key events...

    I think in someway I stoped the ActiveScheduler of the UI. But I don't call the ActiveScheduller::Stop() in any part of my code. I'm using Symbian S60 3rd MR. The ActiveScheduller I'm using is the one installed by the UI itself.

    Any clues?

    Best Regards,

    LSK

  2. #2
    Regular Contributor
    Join Date
    May 2005
    Location
    Sweden
    Posts
    272

    Re: ActiveObject RunL is called just once

    You shouldn't assign a value to iStatus. That will be done by the asynchronous service provider that you call before SetActive(). Do you actually make the request the second time?

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    6

    Re: ActiveObject RunL is called just once

    Hello,

    I wrote the service provider, so I have to set this anyway, but it is in another thread. The comunication between them is made by messages, not method calls.

    I fixed this problem sending the Thread Id of the AO. As the ASP is running in another thread, the call to RThread::RequestComplete() should be done with the callers Thread id. This fixed the problem.

    What I can't understand is why it works for the first time.

    It would be interesting to know how RTimer does this, as the only parameter sent to it is iStatus. I think this is managed internally when you create the RTimer object in your AO thread.

    Do you think iStatus have to be set in the other Thread?

    Thank you for answering,

    LSK

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    6

    Talking Re: ActiveObject RunL is called just once

    This is the fix:

    RThread control;
    ...
    control.Open(f->threadID);
    ...

    DEBUG("Setting status");
    TRequestStatus * pstatus = &f->iStatus;
    control.RequestComplete(pstatus,KErrNone);
    DEBUG("Status set to KErrNone");

    And now it works. It would be nice if there is a simpler way.

    Best Regards,

    LSK

Similar Threads

  1. RunL() is not being called...Please Help
    By emailatravi in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2006-12-27, 09:04
  2. Replies: 5
    Last Post: 2006-03-10, 07:37
  3. SIP : RunL in response to connect is not called up....
    By saurbh_g in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2005-02-09, 04:50
  4. RunL() method is not being called
    By dotcdotc in forum Symbian
    Replies: 9
    Last Post: 2004-12-13, 11:25
  5. RunL() is called when creating CAknWaitDialog
    By Thomas_ in forum Symbian
    Replies: 2
    Last Post: 2004-11-11, 09:59

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×