×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    309

    Smile question about the active object

    Thanks a lot.
    Last edited by liuxingyu_best; 2009-01-06 at 11:08.

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: question about the active object

    yes it can run concurrently

  3. #3
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    309

    Smile Re: question about the active object

    Thanks a lot.
    Last edited by liuxingyu_best; 2009-01-06 at 11:08.

  4. #4
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: question about the active object

    first of all why do you want to have 2 threads, u can easily do with 2 active objects in the same thread. This will make your life simpler !!!

    However, if you still want to have 2 threads, then you might have to use some thread communication mechanism.
    It could be through client-server, or message passing, or shared heap, or simply active objects synchronized way, where in the heap is shared and hence by basic active objects you can pass messages.
    Amit Kankani
    Nokia Developer Champion

  5. #5
    Registered User
    Join Date
    Jun 2008
    Location
    beauty
    Posts
    11

    Re: question about the active object

    Quote Originally Posted by liuxingyu_best View Post
    Thank you for your reply,

    now the problem is cocurrency, I want to use the active object to read some data from file, and then I want to display these data in the main thread. Due to the cocurrency, the code used for displaying data in the main thread is alway executed before end of the execution of the active object. Therefore, every time I can't extract the right data from the active object.

    How can I solve it?

    Thank you

    may be u'd better create a flag, u should set it to ETrue then the thread read data from file completely, on the other hand the main thread should display the data after check the flag.
    As heaven maintains vigor through movements, a gentle man should constantly strive for self-perfection.

  6. #6
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    309

    Smile Re: question about the active object

    Thanks a lot.
    Last edited by liuxingyu_best; 2009-01-06 at 11:08.

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

    Re: question about the active object

    Quote Originally Posted by liuxingyu_best View Post
    I define a active object. can the active object be executed as another thread against the main thread?
    No, it can not. There are not any extra threads in your code until you explicitly start using RThread.
    Active objects are basically callbacks invoked by the Active Scheduler running in your "main thread". This inherently means that there is no 'concurrency' between active objects, one runs after the other. That is why RunL methods have to return fast, and it also applies to methods from M-classes and TCallBack.

  8. #8
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: question about the active object

    I am little confused, are you creating a separate thread yourself in the code, something like
    RThread thread;
    thread.Create(....);
    thread.Resume(...);
    well if not then it is a single thread you are working on.
    In case of single thread, you can do this, once the active object has read the data, then you can call DrawNow or DrawDeferred of the particular container being shown.
    Amit Kankani
    Nokia Developer Champion

  9. #9
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: question about the active object

    i.e. in the RunL of the active object, you can call draw of the current container, or change view, etc, depending on your application logic. !
    Amit Kankani
    Nokia Developer Champion

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: question about the active object

    Quote Originally Posted by liuxingyu_best View Post
    I want to use the active object to read some data from file, and then I want to display these data in the main thread. Due to the cocurrency, the code used for displaying data in the main thread is alway executed before end of the execution of the active object. Therefore, every time I can't extract the right data from the active object.
    RunL method of your AO is the perfect place for doing that 'extraction'. You can freely launch a note/any other popup from that RunL, or do anything else.

  11. #11
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    309

    Smile Re: question about the active object

    Thanks a lot.
    Last edited by liuxingyu_best; 2009-01-06 at 11:08.

  12. #12
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    309

    Re: question about the active object

    Thanks a lot.
    Last edited by liuxingyu_best; 2009-01-06 at 11:08.

  13. #13
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: question about the active object

    Why do not you use [CODE ] and [/CODE ] tags (without the spaces)? It preserves your formatting for example.

    Anyway, note that OnContentL may be invoked multiple times, and in that cases you simply overwrite old content. This kind of code can be debugged in the emulator, so you can try that.

  14. #14
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: question about the active object

    Yes rightly said, you should use [CODE ] tags when posting code so that we can read it easily.

    Also OnContentL , you should be appending to old values and not simply assigning.

    Also AppendItemsL is called when. Make sure you call it once the parsing is DONE...

    Use breakpoints to check the same.
    Amit Kankani
    Nokia Developer Champion

  15. #15
    Registered User
    Join Date
    May 2008
    Posts
    21

    Re: question about the active object

    Hi,

    Can you please elaborate more on the situation.

Similar Threads

  1. active object call inside another active object
    By maina1976 in forum Symbian
    Replies: 4
    Last Post: 2008-08-25, 13:05
  2. Using Active Object?
    By xcompass in forum Symbian
    Replies: 9
    Last Post: 2007-06-29, 12:30
  3. Send and Receive with Active Object
    By wysspeter in forum Symbian Networking & Messaging (Closed)
    Replies: 14
    Last Post: 2007-06-28, 08:30
  4. Question about disconnecting and Active Objects
    By HansProve in forum Bluetooth Technology
    Replies: 2
    Last Post: 2005-09-21, 13:57
  5. waiting for an active object
    By dalore in forum Symbian
    Replies: 3
    Last Post: 2003-06-19, 13:16

Posting Permissions

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