Class LatestMailbox<T>
A thread-safe mailbox that always holds at most one message of type T.
When a new message is added, it overwrites any existing message.
This is useful in scenarios where only the most recent message is relevant,
such as UI or viewport updates, and outdated messages should be ignored.
Inherited Members
Namespace: Mapsui.Fetcher
Assembly: Mapsui.dll
Syntax
public class LatestMailbox<T> where T : class
Type Parameters
| Name | Description |
|---|---|
| T | The type of message to store. Must be a reference type. |
Properties
| Edit this page View SourceIsEmpty
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
| Edit this page View SourceOverwrite(T)
Stores the specified message in the mailbox, replacing any previous message. If a message was already present, it is discarded and replaced by the new one.
Declaration
public void Overwrite(T message)
Parameters
| Type | Name | Description |
|---|---|---|
| T | message | The message to store. Cannot be null. |
TryTake(out T)
Attempts to retrieve and remove the current message from the mailbox. If a message is present, it is returned and the mailbox is cleared. If no message is present, returns false.
Declaration
public bool TryTake(out T message)
Parameters
| Type | Name | Description |
|---|---|---|
| T | message | When this method returns, contains the message retrieved from the mailbox, or null if the mailbox was empty. |
Returns
| Type | Description |
|---|---|
| bool | True if a message was present and retrieved; false if the mailbox was empty. |