Skip to content

Instantly share code, notes, and snippets.

@tomorgan
Last active August 29, 2015 14:04
Show Gist options
  • Save tomorgan/4735f4373b6cb66e15c5 to your computer and use it in GitHub Desktop.
Save tomorgan/4735f4373b6cb66e15c5 to your computer and use it in GitHub Desktop.
Async Begin..End example
private void MyMethod() {
//do some stuff
var flow = GetFlowFromSomewhere();
var message = GetMessageFromSomewhere();
flow.BeginSendInstantMessage(message, EndBeginSendInstanceMessage, flow);
//do some other things....
}
private static void EndBeginSendInstantMessage(IAsyncResult ar)
{
try
{
InstantMessagingFlow flow = (InstantMessagingFlow)ar.AsyncState;
flow.EndSendInstantMessage(ar);
}
catch (Exception ex)
{
//do something with this error
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment