Created
August 20, 2010 02:44
-
-
Save koush/539485 to your computer and use it in GitHub Desktop.
This file contains 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 Android.App; | |
using Android.Content; | |
using Android.Runtime; | |
using Android.Views; | |
using Android.Widget; | |
using Android.OS; | |
using System.Threading; | |
namespace HelloDroid | |
{ | |
public class Activity1 : Activity, Java.Lang.IRunnable | |
{ | |
int count = 1; | |
Android.OS.Handler mHandler = new Handler(); | |
public Activity1(IntPtr handle) | |
: base(handle) | |
{ | |
} | |
Button button; | |
protected override void OnCreate(Bundle bundle) | |
{ | |
base.OnCreate(bundle); | |
// Create your application here | |
button = new Button(this); | |
button.Text = "Click Me!"; | |
button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); }; | |
SetContentView(button); | |
byte[] stuff = new byte[200]; | |
var thread = new Thread(() => | |
{ | |
byte[] foo = new byte[94934]; | |
Thread.Sleep(2000); | |
// this will cause an activity not responding. the gc's call to pthread_kill fails with EPERM | |
// and deadlocks the app. | |
System.GC.Collect(); | |
mHandler.Post(this); | |
} | |
); | |
thread.Start(); | |
} | |
public void Run() | |
{ | |
button.Text = "thread done!"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment