KB-20071228-042

From Triled Wiki

Jump to: navigation, search

simplified code example (from original post):

  msg1.what = 1;
  sendMessageAtFrontOfQueue(msg1);

  msg2.what = 2;
  sendMessageAtFrontOfQueue(msg2);

msg2 was asked to be placed at the front of the queue chronologically after msg1. So, correct order: msg2, msg1.

However, the order seen by android.os.Handler.handleMessage is msg1 comes first, then msg2.

NOTE:
As explored by author of bug (see provided link) sendMessageAtFrontOfQueue calls android.os.MessageQueue.enqueueMessage(msg, when)
with when = 0. This function places second message after first, cause of equal when value. There is no documentation, if this is
expected behaviour, but method  sendMessageAtFrontOfQueue(Message msg) must (as  said in documentation) "Enqueue a message at the
front of the message queue, to be processed on the next iteration of the message loop.", so at least for sendMessageAtFrontOfQueue()
this is definitely bug.
Personal tools