×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    4

    Question Animated icon during processing

    Hi!
    I looked for this discussion, but didn't found, so... sorry if repeated!

    I have an application that, sometimes, takes so much time for doing things. Then, I'd like to show something like an animated icon to the user while doing the processing. This icon must not hide the program's screen, i want it to be in a layer above.

    I have a Canvas class. From the keyPressed method, I call Timer.schedule() for paint the icon's frames in the given period. So, I have the processing, and then Timer.cancel(). Then I call repaint() for have the program back.

    My problem is: the calls for repaint() that should draw my icon effectively happen just after the end of keyPressed. In other words, the icon comes and goes fast, and after the end of the processing.

    I tried to put a serviceRepaints() after the repaint() in the method run() of the TimerTask. But this way the timer stays blocked in this call until the end of keyPressed! If I call just paint(g), the routine is called, but the effect comes to screen just after the end of keyPressed...

    I think maybe the keyPressed method blocks the repaint... but I don't know why...

    Someone knows how could I do this?

    Thanks so much for the attention!

    Francieli

  2. #2
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Re: Animated icon during processing

    Quote Originally Posted by francielizanon View Post
    Hi!
    I looked for this discussion, but didn't found, so... sorry if repeated!

    I have an application that, sometimes, takes so much time for doing things. Then, I'd like to show something like an animated icon to the user while doing the processing. This icon must not hide the program's screen, i want it to be in a layer above.

    I have a Canvas class. From the keyPressed method, I call Timer.schedule() for paint the icon's frames in the given period. So, I have the processing, and then Timer.cancel(). Then I call repaint() for have the program back.

    My problem is: the calls for repaint() that should draw my icon effectively happen just after the end of keyPressed. In other words, the icon comes and goes fast, and after the end of the processing.

    I tried to put a serviceRepaints() after the repaint() in the method run() of the TimerTask. But this way the timer stays blocked in this call until the end of keyPressed! If I call just paint(g), the routine is called, but the effect comes to screen just after the end of keyPressed...

    I think maybe the keyPressed method blocks the repaint... but I don't know why...

    Someone knows how could I do this?

    Thanks so much for the attention!

    Francieli
    Francieli welcome to the Forum Nokia. By serviceRepaints() all other paint request should be invoked before this request. The multithreading might helps you. Call another method of main class from the class which extends timertask and that method should create new thread and call repaint() from that. Let us know if any thing does not work there.

  3. #3
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Animated icon during processing

    Events (as a rule) are serialized. That is, another event will not be delivered until the last one has completed. For this reason, you should always ensure that event-handler methods return as quickly as possible.

    So, doing your lengthy processing inside the keyPressed() event is a bad plan. As you have seen, you jam up the entire event mechanism by doing this. Instead, start a separate thread to handle to processing.

  4. #4
    Registered User
    Join Date
    Aug 2008
    Posts
    4

    Re: Animated icon during processing

    Thanks for your responses! =D

    I forgot to tell, but I already tried the multithread option that you described. Had the same problem =\

    Now that you confirmed to me, I'm sure that they're really serialized! I'll study other alternatives. Thanks!

  5. #5
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Animated icon during processing

    A multi-threaded solution will work. You must return from keyPressed() (and other event methods) immediately, and you must call serviceRepaints() after each repaint() call. Try it again, if it doesn't work for you, post some code and I'll help you.

  6. #6
    Registered User
    Join Date
    Aug 2008
    Posts
    4

    Re: Animated icon during processing

    I was talking about the multithread solution that honest_success described.

  7. #7
    Registered User
    Join Date
    Aug 2008
    Posts
    4

    Re: Animated icon during processing

    I'll try what you said, grahamhughes, and then I talk about the results ^^

  8. #8
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: Animated icon during processing

    Hi,
    You can do it ..as per the discussion,so far.
    Can you please tell me that what exactly is the framework of the code,not clear to me,
    I have an application that, sometimes, takes so much time for doing things. Then, I'd like to show something like an animated icon to the user while doing the processing. This icon must not hide the program's screen, i want it to be in a layer above.
    I mean, do you want to show the processing screen while opening the http connection.off course it can be done using the multi threading.
    Thanks,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. Grid app is crashing... need urgent help...
    By shankha in forum Symbian
    Replies: 5
    Last Post: 2010-10-19, 12:07
  2. Python build problem
    By Santehnik.UA in forum Symbian
    Replies: 7
    Last Post: 2008-07-21, 07:34
  3. Replies: 7
    Last Post: 2007-09-05, 10:38
  4. [Pys60, 3rd Ed.] build problems
    By MHOOO in forum Symbian
    Replies: 3
    Last Post: 2007-04-09, 19:00
  5. SIS fails
    By chirag_cel in forum Symbian
    Replies: 8
    Last Post: 2006-11-29, 10:06

Posting Permissions

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