On Wed, Aug 31, 2011 at 9:16 AM, Dmitry Golubovsky <golubov...@gmail.com>wrote:

> Q1: Is post(action) equivalent to postDelayed(action, 0)?
>

Yes.


> Q2: If a view implements a never stopping cycle like this, depending
> on two time parameters, N and T:
>
>        public void timerEvent() {
>                final class Timer implements Runnable {
>                        public void run() {
>                                timerEvent();
>                        }
>                }
>                                native_code(); // guaranteed to run no
> longer than N msecs
>                postDelayed(new Timer(), T);
>        }
>
> what combinations of N and T ranges (including T = 0) are acceptable
> to make sure the view remains responsive to touch and other user-
> generated events, and "force close/wait" dialog does not appear?
>

It will remain responsive because older messages are processes before newer
messages, so you can't starve other messages from the queue by re-posting a
message when you handle it, even with no delay.

More important is balancing CPU use with what you are trying to do.

At 60fps one frame is 20ms, so it generally isn't useful to have a delay
smaller than that.  At the same time, if this is going on the entire time
the user is in your app, if using a delay of 20ms means you are keeping the
CPU running at near 100%, are going to much more quickly drain the battery
(and the user will see this in the battery use report).

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to