-
Notifications
You must be signed in to change notification settings - Fork 76
CallbackMessage
Rico Suter edited this page Jun 3, 2015
·
4 revisions
- Package: MyToolkit
- Platforms: All (PCL)
- Subclasses:
A message base class with a callback to provide a message result.
The following code snippets show how to send a callback message and process its response. The standard way is to call the Messenger's SendAsync()
method and process the returned result (the method may also throw an exception when the callback message fails):
var message = new TextMessage("Message", "Title", MessageButton.YesNo);
var result = await Messenger.Default.SendAsync(message);
if (result.Result == MessageResult.Yes)
{
SampleProperty = "Foo";
}
Or awaiting the callback message's task:
var message = new TextMessage("Message", "Title", MessageButton.YesNo);
Messenger.Default.Send(message);
var result = await message.Task;
Or registering a success callback:
var message = new TextMessage("Message", "Title", MessageButton.YesNo);
message.SuccessCallback = (success, result) => {
// TODO: Check result
}
Messenger.Send(message);