Skip to content

Instantly share code, notes, and snippets.

@johnsheehan
Created July 28, 2010 05:54
Show Gist options
  • Save johnsheehan/493534 to your computer and use it in GitHub Desktop.
Save johnsheehan/493534 to your computer and use it in GitHub Desktop.
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; });
}
@dahlbyk
Copy link

dahlbyk commented Jul 28, 2010

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...

@johnsheehan
Copy link
Author

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