×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: Rthread problem

  1. #1
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Rthread problem

    Hi, I m creating a thread and within that i m just displaying a information note.The program compiles without any errors but when i debug it is showing KERN_EXEC3 with the thread name. The thread is crashing at the memory allocation for the CAknInformationNote object.Here goes the code what i did for creating thread and

    Code:
    TInt* thread_func()
    {
        _LIT( KText, "Hello World!");
        CAknInformationNote* informationNote;
        informationNote = new ( ELeave) CAknInformationNote;   // here it crashes
        informationNote->ExecuteLD(KText);
        delete informationNote;
        return(KErrNone);
    }
    
    void StartThreadL()
    {
    	TInt res;
    	RThread thd;
    	res = thd.Create(_L("MyThread"),(TInt(*)(TAny*))thread_func,KDefaultStackSize + 1000,KMinHeapSize + 10,KMinHeapSize + 100, NULL, (TOwnerType)EOwnerProcess);
    	if (res==KErrNone)
                {
                    thd.Resume();
                }        
            else
                {
               thd.Close();
                }
    }
    BR,
    Saritha
    Last edited by ltomuta; 2008-06-20 at 11:28. Reason: Please use [CODE] [/CODE] when posting code

  2. #2
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Rthread problem

    You are assuming that your thread has a UI environment. I am assuming that it does not. To know for sure call CEikonEnv::Static.
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: Rthread problem

    In your particular case you can use CAknGlobalNote, since CAknGlobal... classes need no UI at all.

  4. #4
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: Rthread problem

    Hi ltomuta, if i want UI environment in my thread what m i supposed to do.

    BR,
    Saritha

  5. #5
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Rthread problem

    Well, first you must start by asking yourself if you need a thread or if the active objects are more suitable. Then if you think that you really need the thread ... think again :)

    If you really need a thread, do you also need UI in it? Why and how much of it?
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  6. #6
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: Rthread problem

    Hi ltomuta,
    We are using threads and we want to use UI in our child thread in order to make a view switch by using ActivateLocalView. Is this possible and can u kindly guide me how to do it??

    BR,
    Saritha

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: Rthread problem

    You need to employ some IPC mechanism, the GUI can not be directly accessed from a secondary thread. If it is a one-time only requirement (the thread can die after then), you can use RThread::Logon or RThread::Rendezvous from your main thread. Otherwise you need to pass a TRequestStatus from the main thread, and RThread::Complete it (note that the RThread should refer to the main thread in this case).
    You can check how Examples\Base\IPC\Async\Fibonacci2 handles this task.

  8. #8
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: Rthread problem

    Hi Wizard_hu, please confirm me , if i use active objects i can access UI. If yes how to do it . Using threads is the better and easy way to do it or with the active objects ?

    BR,
    Saritha

  9. #9
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Rthread problem

    In Symbian one should always consider using the AO rather than threads, and yes, AO run within the main thread therefore they can access the UI. Yes, it is better (most of the time) and yes it is easier to use (once you learn how). :)

    As for "how to do it?" the answer is "how to do what?"
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  10. #10
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: Rthread problem

    Hi ltomuta,
    I meant I need to do the view switching in my child thread(or active object as u prefer) by using ActivateLocalViewL. So if i use AO can i use ActivateLocalViewL in RunL function, does this work fine??

    BR,
    Saritha

  11. #11
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Rthread problem

    Yes, you can call that method from RunL if you so wish.
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  12. #12
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: Rthread problem

    Hi ltomuta, I have a doubt while using active objects . I m not getting where to issue the request. My asynchronous request is when ever a global variable(flag) is set , a view need to be switched. View switching code is implemented in RunL() function. But where to issue the request. I reffered the below link
    http://wiki.forum.nokia.com/index.php/Active_object , here a function DoAsyncAction() is used to issue the request. But I m not getting how to do it for my requirement.
    void CMyActiveObject::DoAsyncAction(MMyActiveObjectObserver* aObserver)
    {
    __ASSERT_ALWAYS(!IsActive(), User::Panic(KMyActivePanic, EAlreadyActive));
    __ASSERT_ALWAYS(aObserver, User::Panic(KMyActivePanic, ENoObserver));
    iServiceProvider.DoService(iStatus); // issue request to service provider
    SetActive();
    }

    BR,
    saritha

  13. #13
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Rthread problem

    Saritha,

    what is your application supposed to do (other that view switching)? What triggers that flag to change and who/what changes it?
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  14. #14
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: Rthread problem

    Hi ltomuta, We are porting sip stack to symbian. we are in the end of project. But now we are stuck in displaying call status. My boss told me to switch to a view that should contian status and few other contorls within the view. In the sip stack they are setting a global flag based on the retrieved packet ie. 180 ringing etc. I just need to switch a corresponding view when the flag is set.

    BR,
    Saritha

  15. #15
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    75

    Re: Rthread problem

    Hi ltomuta, sorry for disturbing with many queries. I just want my active object to invoke RunL() when the flag is set.How to do this?
    Waiting for reply.


    BR,
    Saritha

Similar Threads

  1. Problem in RThread
    By kalyanich in forum Symbian
    Replies: 1
    Last Post: 2007-06-15, 11:11
  2. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  3. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36
  4. 7210 Silent Problem
    By MarkMckim in forum Mobile Java General
    Replies: 1
    Last Post: 2003-03-18, 12:36
  5. Problem with CMdaAudioPlayerUtility and RThread
    By EduardFrank in forum Symbian
    Replies: 1
    Last Post: 2002-10-14, 18:26

Posting Permissions

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