开发者

How to flush pending messages and callbacks in a Handler

How to flush/dispatch all pending messages and callbacks which are waiting in a Handler?

I need this to deal with certain asynchronous events when my Service is being destroyed.

I want to dispatch all the messages/callbacks immedi开发者_开发知识库ately, not to remove them. I don't use any delayed messages.


Assuming you don't use any delayed messages, you have a queue of pending messages each of which must be processed in associated thread. This means that thread can not process next message unless current message processing is completed.

So, to summarize, if no delayed messages are used, you handler's message loop is already doing its best to flush the queue. The only thing that can make this flushing faster is better message processing. And this is not Handler's work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜