Created
February 21, 2012 00:37
-
-
Save gshackles/1872574 to your computer and use it in GitHub Desktop.
async sample
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
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Android.App; | |
using Android.Widget; | |
using Android.OS; | |
namespace MonoAndroidApplication18 | |
{ | |
[Activity(Label = "MonoAndroidApplication18", MainLauncher = true, Icon = "@drawable/icon")] | |
public class Activity1 : Activity | |
{ | |
protected override void OnCreate(Bundle bundle) | |
{ | |
base.OnCreate(bundle); | |
SetContentView(Resource.Layout.Main); | |
var button = FindViewById<Button>(Resource.Id.MyButton); | |
button.Text = "Before task starts"; | |
Task.Factory.StartNew(() => | |
{ | |
Thread.Sleep(5000); | |
RunOnUiThread(() => | |
button.Text = "Task is complete"); | |
}); | |
button.Text = "After task starts"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment