×

Discussion Board

Results 1 to 6 of 6

Thread: Threads

  1. #1
    Regular Contributor
    Join Date
    Nov 2006
    Location
    Switzerland
    Posts
    476

    Threads

    Hello
    I've an active object that gets some information about battery, etc. Before it goes back to RunL() by calling SetActive(), I'd like to wait for a few seconds to avoid a constant loop. I already tried the usage of...
    - RTimer (After)
    - User::After
    ...but they all suspend the current thread for the time specified so that a user interaction with the application is not possible. Is there a timer-method that doesn't suspend the thread?

  2. #2
    Registered User
    Join Date
    May 2007
    Location
    Poland
    Posts
    606

    Re: Threads

    Hello,
    in the same active object you may create asynchronous timer which you will launch as a break before loops:
    in constructL:
    Code:
    User::LeaveIfError(iTimer.CreateLocal()); // where timer is RTimer iTImer;
    and the function:
    Code:
    void CMyApp::StartL(TTimeIntervalMicroSeconds32 aDelay)
    	{
    	Cancel(); // Cancel any request, just to be sure
    	iTimer.After(iStatus, aDelay); // Set for later
    	SetActive(); // Tell scheduler a request is active
    	}
    ofcourse you will have to set some flag in StartL function to inform RunL that timer has finished it s job and you can start battery check

    Good luck

    Nuker85

  3. #3
    Regular Contributor
    Join Date
    Nov 2006
    Location
    Switzerland
    Posts
    476

    Re: Threads

    And with this method the thread will not be blocked?? I already tried RTimer by using before calling SetActive() by using the code below, but that prevents user interaction completely for 2 seconds...
    Code:
    timer.CreateLocal(); 
    timer.After(timerStatus,2000000); 
    User::WaitForRequest(timerStatus); 
    timer.Close();

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: Threads

    User::WaitForRequest blocks the thread. Active objects do not, that is their purpose.
    After 2 years of active coding and almost 300 posts, you should really consider learning how active objects work. FN Docs section of Symbian C++ contains some documentation on AO's, and I am rather convinced that the Wiki also provides some hits.

  5. #5
    Registered User
    Join Date
    May 2007
    Location
    Poland
    Posts
    606

    Re: Threads

    Like Wizard said, User::WaitForRequest is syncrhonous function when setting active active object is asynchronous

  6. #6
    Regular Contributor
    Join Date
    Nov 2006
    Location
    Switzerland
    Posts
    476

    Re: Threads

    Now I got it! It works! I got marquee effect for each list box item. Permanent user interaction while updating the list box content is assured, too.

    Thank you guys for all your tipps and tricks and finally for your efforts in helping me!

Similar Threads

  1. Replies: 0
    Last Post: 2008-09-22, 11:37
  2. Replies: 3
    Last Post: 2008-01-31, 23:54
  3. Threads List in an application
    By mailkamlesh in forum Symbian
    Replies: 1
    Last Post: 2007-11-26, 08:07
  4. Message to everybody - STOP USING THREADS
    By hotcheese in forum Symbian
    Replies: 8
    Last Post: 2007-03-05, 12:18
  5. mixing AO, threads and sockets
    By mikfi in forum Symbian Networking & Messaging (Closed)
    Replies: 6
    Last Post: 2006-11-21, 23:19

Posting Permissions

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