Created
July 28, 2010 05:54
-
-
Save johnsheehan/493534 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
twilio.SendSmsMessageAsync("5551111111", "5552222222", "Async! ", (msg) => { | |
Dispatcher.BeginInvoke(() => { txtOutput.Text = msg.Sid; }); | |
}); | |
twilio.SendSmsMessageAsync("5551111111", "5552222222", "Async! ", smsSent); | |
public void smsSent(SmsMessage msg) { | |
Dispatcher.BeginInvoke(() => { txtOutput.Text = msg.Sid; }); | |
} | |
// or | |
twilio.SendSmsMessageAsync("5551111111", "5552222222", "Async!"); | |
twilio.SendSmsMessageCompleted += smsCompleted; | |
public void smsCompleted(object sender, SmsCompletedEventArgs e) { | |
Dispatcher.BeginInvoke(() => { txtOutput.Text = e.Message.Sid; }); | |
} |
That looks awesome! I think I need to dig into Rx.........
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Rx, you would have...
IObservable o = twilio.SendSmsMessage("5551111111", "5552222222", "Async!");
And then the consumer would subscribe:
using(var sub = o.Subscribe(smsSent))
{
// Whatever...
}
The real advantage of Rx is composability, but I'm not entirely sure how that would be useful here...