The page has been moved to GitHub

CallbackMessage

Package: MyToolkit
Platforms: All (PCL)

Subclasses: A message base class with a callback to provide a message result.

Usage

This section shows 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);

Last edited Jun 3, 2015 at 9:55 PM by rsuter, version 12