Created
September 14, 2015 13:50
-
-
Save ptsiogas/7667efd07a293d724fa8 to your computer and use it in GitHub Desktop.
Run Async Task (Xamarin)
This file contains hidden or 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
//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