ptsiogas
9/14/2015 - 1:50 PM

Run Async Task (Xamarin)

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 ();

		}