diff options
author | E.Z. Hart <hartez@users.noreply.github.com> | 2016-09-27 12:05:41 -0600 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-09-27 11:05:41 -0700 |
commit | 0f7b22f49d767c3ae522641c324e7ef6928719b4 (patch) | |
tree | c2ab9c8977928d86b5e860c5f5741e4734fca374 | |
parent | f252238fec90d8f71b49e35212275b9e588964e3 (diff) | |
download | xamarin-forms-0f7b22f49d767c3ae522641c324e7ef6928719b4.tar.gz xamarin-forms-0f7b22f49d767c3ae522641c324e7ef6928719b4.tar.bz2 xamarin-forms-0f7b22f49d767c3ae522641c324e7ef6928719b4.zip |
Reuse Handler when invoking on main thread (#383)
-rw-r--r-- | Xamarin.Forms.Platform.Android/Forms.cs | 9 |
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() |