summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2016-09-16 21:05:29 (GMT)
committerJason Smith <jason.smith@xamarin.com>2016-09-16 21:05:29 (GMT)
commit7d66ed0aada19c7d320186a1a34907d77d38ab0d (patch)
treef964f303755216cee88b9fe969423f0caf231d53 /Xamarin.Forms.Platform.Android
parent5b1bad9a1137b4ec224a937ab7f8405929014e65 (diff)
downloadxamarin-forms-7d66ed0aada19c7d320186a1a34907d77d38ab0d.zip
xamarin-forms-7d66ed0aada19c7d320186a1a34907d77d38ab0d.tar.gz
xamarin-forms-7d66ed0aada19c7d320186a1a34907d77d38ab0d.tar.bz2
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
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r--Xamarin.Forms.Platform.Android/Forms.cs4
1 files changed, 1 insertions, 3 deletions
diff --git a/Xamarin.Forms.Platform.Android/Forms.cs b/Xamarin.Forms.Platform.Android/Forms.cs
index a2a063c..c2dc770 100644
--- a/Xamarin.Forms.Platform.Android/Forms.cs
+++ b/Xamarin.Forms.Platform.Android/Forms.cs
@@ -264,9 +264,7 @@ namespace Xamarin.Forms
public void BeginInvokeOnMainThread(Action action)
{
- var activity = Context as Activity;
- if (activity != null)
- activity.RunOnUiThread(action);
+ new Handler(Looper.MainLooper).Post(action);
}
public Ticker CreateTicker()