summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-09-27 12:05:41 -0600
committerJason Smith <jason.smith@xamarin.com>2016-09-27 11:05:41 -0700
commit0f7b22f49d767c3ae522641c324e7ef6928719b4 (patch)
treec2ab9c8977928d86b5e860c5f5741e4734fca374 /Xamarin.Forms.Platform.Android
parentf252238fec90d8f71b49e35212275b9e588964e3 (diff)
downloadxamarin-forms-0f7b22f49d767c3ae522641c324e7ef6928719b4.tar.gz
xamarin-forms-0f7b22f49d767c3ae522641c324e7ef6928719b4.tar.bz2
xamarin-forms-0f7b22f49d767c3ae522641c324e7ef6928719b4.zip
Reuse Handler when invoking on main thread (#383)
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r--Xamarin.Forms.Platform.Android/Forms.cs9
1 files changed, 8 insertions, 1 deletions
diff --git a/Xamarin.Forms.Platform.Android/Forms.cs b/Xamarin.Forms.Platform.Android/Forms.cs
index c2dc770b..6f3346fb 100644
--- a/Xamarin.Forms.Platform.Android/Forms.cs
+++ b/Xamarin.Forms.Platform.Android/Forms.cs
@@ -262,9 +262,16 @@ namespace Xamarin.Forms
double _microSize;
double _smallSize;
+ static Handler s_handler;
+
public void BeginInvokeOnMainThread(Action action)
{
- new Handler(Looper.MainLooper).Post(action);
+ if (s_handler == null || s_handler.Looper != Looper.MainLooper)
+ {
+ s_handler = new Handler(Looper.MainLooper);
+ }
+
+ s_handler.Post(action);
}
public Ticker CreateTicker()