Handler.RemoveMessages Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| RemoveMessages(Int32) |
Remove any pending posts of messages with code 'what' that are in the message queue. |
| RemoveMessages(Int32, Object) |
Remove any pending posts of messages with code 'what' and whose obj is 'object' that are in the message queue. |
RemoveMessages(Int32)
Remove any pending posts of messages with code 'what' that are in the message queue.
[Android.Runtime.Register("removeMessages", "(I)V", "")]
public void RemoveMessages(int what);
[<Android.Runtime.Register("removeMessages", "(I)V", "")>]
member this.RemoveMessages : int -> unit
Parameters
- what
- Int32
The message identifier.
- Attributes
Remarks
Remove any pending posts of messages with code 'what' that are in the message queue.
Note that `Message#what` is 0 unless otherwise set. When calling `postMessage(Runnable)` or `postAtTime(Runnable, long)`, the `Runnable` is internally wrapped with a `Message` whose `what` is 0. Calling `removeMessages(0)` will remove all messages without a `what`, including posted `Runnable`s.
This operation is worst case O(n) in the number of messages in the queue, and should be avoided. Instead consider another mechanism outside of the queue to cancel a pending operation. For instance, maintain a flag to indicate whether the operation should be performed differently or not at all once it is dispatched.
Java documentation for android.os.Handler.removeMessages(int).
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
RemoveMessages(Int32, Object)
Remove any pending posts of messages with code 'what' and whose obj is 'object' that are in the message queue.
[Android.Runtime.Register("removeMessages", "(ILjava/lang/Object;)V", "")]
public void RemoveMessages(int what, Java.Lang.Object? object);
[<Android.Runtime.Register("removeMessages", "(ILjava/lang/Object;)V", "")>]
member this.RemoveMessages : int * Java.Lang.Object -> unit
Parameters
- what
- Int32
The message identifier.
- object
- Object
The value may be null.
- Attributes
Remarks
Remove any pending posts of messages with code 'what' and whose obj is 'object' that are in the message queue. If <var>object</var> is null, all messages will be removed.
This operation is worst case O(n) in the number of messages in the queue, and should be avoided. Instead consider another mechanism outside of the queue to cancel a pending operation. For instance, maintain a flag to indicate whether the operation should be performed differently or not at all once it is dispatched.
Java documentation for android.os.Handler.removeMessages(int, java.lang.Object).
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.