×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    197

    Post Set active of secondary thread AO in main thread

    Hello,

    I created an active object in secondary thread,
    and then I called its SetActive() in main thread,

    but this raised a panic E32USER-CBase 46,
    the SDK help doc states "This panic is raised by an active scheduler, a CActiveScheduler. It is caused by a stray signal".

    What's wrong with this?
    How to sovle this problem?
    //---------------------------------------------------------------------------------
    Stand on the shoulders of the Great and build a better world.
    //---------------------------------------------------------------------------------

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: Set active of secondary thread AO in main thread

    you either forgot to add your AO to the active scheduler, or you forgot to start any request, or you forgot to call SetActive() for teh request, of course you also need to add the active scheduler for your new thread, it is not automatically made for it.

  3. #3
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    197

    Post Re: Set active of secondary thread AO in main thread

    Quote Originally Posted by symbianyucca View Post
    you either forgot to add your AO to the active scheduler, or you forgot to start any request, or you forgot to call SetActive() for teh request, of course you also need to add the active scheduler for your new thread, it is not automatically made for it.
    All you mentoined I have done,
    this panic still occured,

    One more point I forget to tell is that this panic is raised for main thread,
    secondary thread is runing normally.
    //---------------------------------------------------------------------------------
    Stand on the shoulders of the Great and build a better world.
    //---------------------------------------------------------------------------------

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: Set active of secondary thread AO in main thread

    then I'm a bi puzzled, anyway, so all I can say is to check all AO handlings in your application,.

  5. #5
    Regular Contributor
    Join Date
    Apr 2008
    Location
    India
    Posts
    477

    Re: Set active of secondary thread AO in main thread

    Quote Originally Posted by leejx View Post
    Hello,

    I created an active object in secondary thread,
    and then I called its SetActive() in main thread,

    but this raised a panic E32USER-CBase 46,
    the SDK help doc states "This panic is raised by an active scheduler, a CActiveScheduler. It is caused by a stray signal".

    What's wrong with this?
    How to sovle this problem?
    And how u are calling the SetActive() of secondary thread from main thread?

  6. #6
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: Set active of secondary thread AO in main thread

    hmmm, did not spot that one.. rather good one, if it is really called in main thread, it would be going to wrong active scheduler, and that would explain the whole thingi.

  7. #7
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    197

    Post Re: Set active of secondary thread AO in main thread

    Quote Originally Posted by symbianyucca View Post
    hmmm, did not spot that one.. rather good one, if it is really called in main thread, it would be going to wrong active scheduler, and that would explain the whole thingi.

    I thought this way as you did,
    but how to solve it?
    Any idea?

    Thanks.


    Quote Originally Posted by pawan_G View Post
    And how u are calling the SetActive() of secondary thread from main thread?
    As to this, when I call SetActive() of secondary thread Active Object, RMutex has been used for sync sake.
    //---------------------------------------------------------------------------------
    Stand on the shoulders of the Great and build a better world.
    //---------------------------------------------------------------------------------

  8. #8
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: Set active of secondary thread AO in main thread

    Can you show the active object implementation ?

  9. #9
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    197

    Post Re: Set active of secondary thread AO in main thread

    Quote Originally Posted by symbianyucca View Post
    Can you show the active object implementation ?
    This active object implementation is nothing sepecial as most AOs are,
    maybe I could show you how I called its SetActive(), this may be more helpful.

    Code:
    myThread.Create( myThreadName, SecondaryThreadFunction,... /*the rese paras are omitted*/)
    
    //  this is local static function to create active scheduler etc
    static TInt SecondaryThreadFunction
    {
    // code to create CTrapCleanup is here and omitted...
    // code to create, install active scheduler
    
    MyActiveObject* myAO = MyActiveObject::NewL();
    // NOTE : pointer to myAO is transferred to main thread by user
    
    CleanupStack::PushL( myAO );
    CActiveScheduler::Add( myAO );
    
    CActiveScheduler::Start();
    
    // code to delete CTrapCleanup is here and omitted
    }
    
    
    // in main thread
    myAO->Start() // this Start will call SetActive() etc, and after this call that panic is raised for main thread
                  // and secondary thread is running normally
    //---------------------------------------------------------------------------------
    Stand on the shoulders of the Great and build a better world.
    //---------------------------------------------------------------------------------

  10. #10
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: Set active of secondary thread AO in main thread

    I would call myAO->Start() before the CActiveScheduler::Start();

  11. #11
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    197

    Post Re: Set active of secondary thread AO in main thread

    Quote Originally Posted by symbianyucca View Post
    I would call myAO->Start() before the CActiveScheduler::Start();
    I knew that there must be at least one outstanding AO on active scheduler,
    so in fact, I have another AO set active before CActiveScheduler::Start().

    I have to start that AO in main thread for some reason.
    //---------------------------------------------------------------------------------
    Stand on the shoulders of the Great and build a better world.
    //---------------------------------------------------------------------------------

  12. #12
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: Set active of secondary thread AO in main thread

    Then can you show the actual active object implementation parts..

  13. #13
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    197

    Post Re: Set active of secondary thread AO in main thread

    Quote Originally Posted by symbianyucca View Post
    Then can you show the actual active object implementation parts..
    Is its implementation so important?
    Why?

    It's quite a big part..
    //---------------------------------------------------------------------------------
    Stand on the shoulders of the Great and build a better world.
    //---------------------------------------------------------------------------------

  14. #14
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: Set active of secondary thread AO in main thread

    just omit parts that are not necessary.

  15. #15
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,675

    Re: Set active of secondary thread AO in main thread

    In a multi-threaded environment it is extremely important that CActiveScheduler::Add, usage of iStatus, calling SetActive and completion of the request must happen in one single thread. Practically it means that you should use the active object in the same thread where you have created it.
    Otherwise RMutex has has nothing to do with active objects, it does not provide any asynchronous functions.

Similar Threads

  1. Why don't S60 emulator loading?
    By K.John in forum Feedback - Nokia Developer Services & Infrastructure
    Replies: 9
    Last Post: 2009-08-11, 11:03
  2. console app running problem
    By xcompass in forum Symbian
    Replies: 3
    Last Post: 2009-05-08, 13:26
  3. Replies: 2
    Last Post: 2007-10-05, 20:40
  4. Active Object and Thread
    By alexdoor73 in forum Symbian
    Replies: 0
    Last Post: 2002-12-02, 07:19
  5. Active Object and Thread
    By alexdoor73 in forum Symbian
    Replies: 0
    Last Post: 2002-11-29, 14:54

Posting Permissions

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