Skip to content

Instantly share code, notes, and snippets.

@ptsiogas
Created September 14, 2015 13:50
Show Gist options
  • Save ptsiogas/7667efd07a293d724fa8 to your computer and use it in GitHub Desktop.
Save ptsiogas/7667efd07a293d724fa8 to your computer and use it in GitHub Desktop.
Run Async Task (Xamarin)
//Async method
public void requestInputAsync() {
//The worker does all the work for you.
BackgroundWorker requestInputWorkerNew = new BackgroundWorker ();
requestInputWorkerNew.DoWork += new DoWorkEventHandler (delegate(object o, DoWorkEventArgs args) {
//Do all the async work here but for God's sake don't mess with the UI Thread
}
});
requestInputWorkerNew.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
delegate(object o, RunWorkerCompletedEventArgs args)
{
//here you can even change UI elements
});
//Don't forget to start the worker async
requestInputWorkerNew.RunWorkerAsync ();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment