Unfortunately my RenderTask varies from about .5seconds - 5 seconds.  So, 
it is very undesirable to either perform it on the UI thread, or to force 
the UI thread to wait on it.  

Any idea what causes the ImageButton.draw() to hang, its possible the 
hanging is preventable/fixable?

On Tuesday, 24 April 2012 13:37:41 UTC-4, Nathan wrote:
>
> Yes, indeed there are potential synchronization issues. I've done some of 
> this myself. 
>
> You may want to use something like: 
> java.util.concurrent.locks.ReentrantLock;
>
> Lock, draw to, and then release. 
>
> Lock, draw from, and then release. 
>
> This can work if you are sure you are locking it only for short periods. 
> Don't wait for any network or database traffic while the lock is on. 
>
> The UI will block in onDraw if your worker task is drawing. If the draw 
> operation takes 10 milliseconds, this isn't bad. If it takes four seconds 
> it will be bad and cause an ANR.   
>
> There may be other ways of handing it also, but yes, what you are doing 
> now is not very safe. 
>
> Nathan 
>
>
>

-- 
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