×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    140

    why the RunL() is not called ?(About CActive!)

    hello everybody,

    I am having a trouble in the use of the class CActive.

    It's the special description as follows:

    I declare a class first:

    class CTest: public CActive
    {
    CTest* NewL();
    CTest* NewLC();
    CTest();
    ~CTest();
    void Start();
    void RunL();
    void DoCancel();
    }

    and the key part of implementation is following:

    CTest::CTest():CActive(EPriorityHigh)
    {
    CActiveScheduler::Add(this);
    }

    CTest::Start()
    {
    SetActive();
    }

    CTest::~CTest()
    {
    Cancel();
    }

    It's all!

    Now, I can't find the problem why the function of RunL() is not called after the Start() function is called by UI interface class.

    Can anybody help me find the answer? thanks in advance!

    Best regards!
    sophie
    Last edited by yfw1966; 2008-05-28 at 11:27.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: why the RunL() is not called ?(About CActive!)

    Nothing happens with your iStatus, that is why.
    SetActive indicates that your object is going to consume an event. However no event happens.
    You can introduce a timer for example
    Code:
    class CTest: public CActive
    {
        CTest* NewL();
        CTest* NewLC();
        CTest();
        ~CTest();
        void Start();
        void RunL();
        void DoCancel();
        void ConstructL();
        RTimer iTimer;
    }
    
    void CTest::ConstructL() // if you have NewL/NewLC, you probably already have an empty ConsturctL
    {
        User::LeaveIfError(iTimer.CreateLocal());
    }
    
    CTest::Start()
    {
        iTimer.After(iStatus,10*1000*1000); // 10 seconds
        SetActive();
    }
    
    void CTest::DoCancel()
    {
        iTimer.Cancel();
    }
    
    CTest::~CTest()
    {
        Cancel();
        iTimer.Close();
    }
    or you can just trigger yourself instead:
    Code:
    CTest::Start()
    {
        TRequestStatus *status=&iStatus;
        User::RequestComplete(status,KErrNone);
        SetActive();
    }
    By the way, notice the usage of [ CODE ] tags.

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    140

    Re: why the RunL() is not called ?(About CActive!)

    Thank you very much, wizard_hu_.

    I made a test before comding here.
    I just added the line "iTimer.After(iStatus,10*1000*1000); " It's almost the same as your description before. as a result, It can run correctlly. so, as you said:"Nothing happens with your iStatus" .
    But,now I can not understand why some time delay must be set before SetActive() is called?

    Thanks again, and I get more than the answer to the question.

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    140

    Re: why the RunL() is not called ?(About CActive!)

    hello wizard_hu_,

    I think the answer to my last question "I can not understand why some time delay must be set before SetActive() is called?" shoud be the following:

    "One Object can only has a request transaction at the same time,because the object owns only one iStatus! That is to say, the next request can not be set active until the last request complete."

    Do you think so? thanks!

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: why the RunL() is not called ?(About CActive!)

    Quote Originally Posted by yfw1966 View Post
    But,now I can not understand why some time delay must be set before SetActive() is called?
    No, that is not a delay "before SetActive".
    Active objects are waiting for completion of asynchronous requests.
    - the SetActive notifies the Active Scheduler, that sooner or later such an asynchronous request will be completed. If you forget calling the SetActive, and your request still completes, it is going to be a so called "stray signal" (E32USER-CBase 46 panic), since no one stated that he is expecting a request completion
    - and the request completion itself happens when someone invokes RThread::RequestComplete on your iStatus. So that iTimer.After does not wait before SetActive, your code will proceed immediately. However a the timer (which works independently from your code) will issue the RequestComplete on your iStatus after 10 seconds, and after that your RunL will be invoked soon.
    Manual invocation of User::RequestComplete simply completes immediately a request for the current thread.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: why the RunL() is not called ?(About CActive!)

    Quote Originally Posted by yfw1966 View Post
    "One Object can only has a request transaction at the same time,because the object owns only one iStatus! That is to say, the next request can not be set active until the last request complete."
    Exactly :-) One active object can wait for one asynchronous request at a time. But you can have arbitrary number of active objects in your code.

  7. #7
    Registered User
    Join Date
    Mar 2008
    Posts
    140

    Re: why the RunL() is not called ?(About CActive!)

    hello wizard_hu_,

    Thanks , I think I need time to think it over.
    now , I have to go to bed for beautiful tomorrow.

    see you latar!

  8. #8
    Registered User
    Join Date
    Mar 2008
    Posts
    140

    Re: why the RunL() is not called ?(About CActive!)

    hello wizard_hu_,

    I have understood the use of CActive, I can describe it as follows:

    first, we use setactive() to launch a active object.
    then, everything is the same, it will go to the end after beginning.
    so we use User::RequestComplete() or iTimer.after() to complete an asynchronous request originating in the same thread.

    Thanks very much!

    Best regards!
    sophie
    Last edited by yfw1966; 2008-05-29 at 02:33.

  9. #9
    Regular Contributor
    Join Date
    Oct 2007
    Location
    China
    Posts
    269

    Re: why the RunL() is not called ?(About CActive!)

    Quote Originally Posted by yfw1966 View Post
    hello wizard_hu_,

    I have understood the use of CActive, I can describe it as follows:

    first, we use setactive() to launch a active object.
    then, everything is the same, it will go to the end after beginning.
    so we use User::RequestComplete() or iTimer.after() to complete an asynchronous request originating in the same thread.

    Thanks very much!

    Best regards!
    sophie
    I advise you read some book about Symbian at first.

  10. #10
    Regular Contributor
    Join Date
    Jan 2007
    Location
    Bangalore
    Posts
    285

    Re: why the RunL() is not called ?(About CActive!)

    RunL() is called after SetActive() only if there is something concrete to be done for example a Socket Read or write.
    I guess you might be just experimenting with CActive Objects, please check its uses and description in the docs.


    Regards
    Shashi Kiran G M


  11. #11
    Registered User
    Join Date
    Mar 2008
    Posts
    140

    Re: why the RunL() is not called ?(About CActive!)

    Quote Originally Posted by gmsk19 View Post
    RunL() is called after SetActive() only if there is something concrete to be done for example a Socket Read or write.

    Regards
    Shashi Kiran G M

    Actually I don't agree with you. I think you have not met some instances where the CActive is used by different ways. e.g., when you just want to launch a RunL(), but do not create any connections with RSocket or others. at this time , you will find your point of view is very unilateral.
    Last edited by yfw1966; 2008-05-30 at 13:52.

  12. #12
    Registered User
    Join Date
    Mar 2008
    Posts
    140

    Re: why the RunL() is not called ?(About CActive!)

    Quote Originally Posted by andy205214 View Post
    I advise you read some book about Symbian at first.
    I think it is better to show your point of view very clearly here. in addition,if you have referred S60 SDK before coming here, you will find the sentences I wrote are all from the S60 SDK. or, I do not think you have understood me very well.

  13. #13
    Registered User
    Join Date
    Mar 2008
    Posts
    140

    Re: why the RunL() is not called ?(About CActive!)

    hello everybody!

    I think I have got the solution on my question at present.
    At the same time, I hope the information can be shared by all here. and hope the one who have the same trouble with me will also get help.

    Thank everybody for coming here!
    Thank you wizard_hu_ for your answer.

    best regards!
    sophie
    Last edited by yfw1966; 2008-05-30 at 13:23.

Similar Threads

  1. CActive object destructor not called
    By marmirman in forum Symbian
    Replies: 6
    Last Post: 2007-10-29, 06:51
  2. Replies: 6
    Last Post: 2007-06-15, 09:16
  3. ActiveObject RunL is called just once
    By lskmao in forum Symbian
    Replies: 3
    Last Post: 2007-01-18, 15:15
  4. Replies: 2
    Last Post: 2006-08-30, 21:33
  5. Cancelling CActive and RunL
    By yaront in forum Symbian
    Replies: 3
    Last Post: 2005-01-12, 07:45

Posting Permissions

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