Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User AndySH's Avatar
    Join Date
    Mar 2007
    Posts
    56
    I have some question about RThread.
    For example, in my program I create new thread in AppUI class:

    Code:
    iThread.Create(_L("ThreadName"), thread_func, KDefaultStackSize,
    				NULL, this);
    iThread.Resume();
    code of thread_func is:
    Code:
    TInt CTestThreadAppUi::thread_func(TAny* aPtr)
    {
        CTrapCleanup* cleanupStack = CTrapCleanup::New();
        
        TRAPD(err, ((CTestThreadAppUi*)aPtr)->run_test())
        
        delete cleanupStack;
        cleanupStack = NULL;
        return err;
    
    }
    
    void CTestThreadAppUi::run_test()
    {
        CActiveScheduler* activeScheduler = new(ELeave) CActiveScheduler();
        CleanupStack::PushL(activeScheduler); 
        CActiveScheduler::Install(activeScheduler);
        
        iAppView->AddText( _L("Hello") );
        
        CleanupStack::PopAndDestroy(); //activeScheduler
    }
    In my AppView I have CEikEdwin and function AddText which adds string to this edwin.
    Code:
    void CTestThreadAppView::AddText(const TDesC& aText)
    {
        CPlainText* text = iEdwin->Text();
        text->InsertL( text->DocumentLength(), aText );
        text->InsertL( text->DocumentLength(), CEditableText::ELineBreak );
        iEdwin->HandleTextChangedL();
        iEdwin->SetSelectionL( text->DocumentLength(), text->DocumentLength() );
        iEdwin->SetFocus( ETrue );
        DrawNow();
    }
    This function works then I call it from AppUI directly, but if I call if from my RThread this function throws panic KERN-EXEC 0 in string
    Code:
    iEdwin->HandleTextChangedL();
    In my test there are no any other threads.

  2. #2
    Registered User david.caabeiro's Avatar
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678
    Using gui objects in secondary threads is a bad idea. Do it from your main thread, and also, consider using active objects, unless you're really sure of what you are doing.

  3. #3
    Registered User AndySH's Avatar
    Join Date
    Mar 2007
    Posts
    56
    Yes, I agree that it is not good idea, but I wand to know why I receive this panic. Do you have more information than "is a bad idea" ;-)

  4. #4
    Registered User david.caabeiro's Avatar
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678
    CEikEdwin, as related classes, rely on an eikon environment, which is absent in your secondary thread.

  5. #5
    Registered User AndySH's Avatar
    Join Date
    Mar 2007
    Posts
    56
    Thanks a lot for reply!
    Do you know some method to create eikon environment for the RThread, or it is imossible?

  6. #6
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    Quote Originally Posted by AndySH View Post
    Do you know some method to create eikon environment for the RThread, or it is imossible?
    It is possible, CCoeEnv/CEikonEnv (and CAknEnv) are classes which can be instantiated. Anyway, the result will likely not work.
    What do you need exactly?

  7. #7
    Registered User david.caabeiro's Avatar
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678
    You may want to check

    http://pushl.com/developers/exeui.html
    http://pushl.com/developers/exectrl.html

    for some ideas, and do your own tests.. but note that code wasn't tested on 3rd ed, and let me insist you'll run into more trouble than needed..

  8. #8
    Registered User AndySH's Avatar
    Join Date
    Mar 2007
    Posts
    56
    Thanks for reply! It's really interesting and useful info for me. Thanks!

  9. #9
    Super Contributor Paul.Todd's Avatar
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644
    I would be very careful here as the environment already has a GUI on the primary thread.

    Also on OS 9.x the method PushL mentions does seem to be very unstable (at least on ESeries)

    Use active objects to coordinate requests between threads or even better do not use a thread, there are very few use cases that require it

Similar Threads

  1. Engine instantiating the GUI in a new thread
    By savvy in forum Symbian C++
    Replies: 4
    Last Post: 2007-05-15, 15:03
  2. RThread problem
    By miranda2112 in forum Symbian C++
    Replies: 6
    Last Post: 2006-12-15, 10:37
  3. RThread - Totally fogged ..Help !!
    By tektronic in forum Symbian C++
    Replies: 2
    Last Post: 2006-06-27, 16:40

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved