Android BeginInvokeOnMainThread() should not possibly block. (#343)
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 16 Sep 2016 21:05:29 +0000 (06:05 +0900)
committerJason Smith <jason.smith@xamarin.com>
Fri, 16 Sep 2016 21:05:29 +0000 (14:05 -0700)
commit7d66ed0aada19c7d320186a1a34907d77d38ab0d
treef964f303755216cee88b9fe969423f0caf231d53
parent5b1bad9a1137b4ec224a937ab7f8405929014e65
Android BeginInvokeOnMainThread() should not possibly block. (#343)

Android.App.Activity.RunOnUiThread() does not always run the argument
Runnable asynchronously; actually it is run synchronously if current
thread is the UI thread [*1][*2]

Use Handler.Post() instead. (It is also used in Android.App.SyncContext[*3])

[*1] https://developer.android.com/reference/android/app/Activity.html#runOnUiThread(java.lang.Runnable)
[*2] http://stackoverflow.com/questions/33039600/android-runonuithread-not-async
[*3] https://github.com/xamarin/xamarin-android/blob/5777337/src/Mono.Android/Android.App/SyncContext.cs#L15
Xamarin.Forms.Platform.Android/Forms.cs