From b9effb88c8be4021a716079e8cf15d3cdb9af8ed Mon Sep 17 00:00:00 2001 From: Nigel Sampson Date: Mon, 15 Jul 2019 15:34:34 +1200 Subject: [PATCH] #407 Add PropertyChangeNotificationsOnUIThread --- src/Caliburn.Micro.Core/DefaultPlatformProvider.cs | 5 +++++ src/Caliburn.Micro.Core/IPlatformProvider.cs | 5 +++++ .../Platforms/Android/AndroidPlatformProvider.cs | 6 +++++- .../Platforms/Xamarin.Forms/FormsPlatformProvider.cs | 5 +++++ .../Platforms/iOS/iOSPlatformProvider.cs | 5 +++++ src/Caliburn.Micro.Platform/XamlPlatformProvider.cs | 5 +++++ 6 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Caliburn.Micro.Core/DefaultPlatformProvider.cs b/src/Caliburn.Micro.Core/DefaultPlatformProvider.cs index 09bff6b8..de6d215a 100644 --- a/src/Caliburn.Micro.Core/DefaultPlatformProvider.cs +++ b/src/Caliburn.Micro.Core/DefaultPlatformProvider.cs @@ -46,6 +46,11 @@ public virtual void OnUIThread(Action action) action(); } + /// + /// Whether or not classes should execute property change notications on the UI thread. + /// + public virtual bool PropertyChangeNotificationsOnUIThread => true; + /// /// Used to retrieve the root, non-framework-created view. /// diff --git a/src/Caliburn.Micro.Core/IPlatformProvider.cs b/src/Caliburn.Micro.Core/IPlatformProvider.cs index 3795bc65..e314efc9 100644 --- a/src/Caliburn.Micro.Core/IPlatformProvider.cs +++ b/src/Caliburn.Micro.Core/IPlatformProvider.cs @@ -15,6 +15,11 @@ public interface IPlatformProvider /// bool InDesignMode { get; } + /// + /// Whether or not classes should execute property change notications on the UI thread. + /// + bool PropertyChangeNotificationsOnUIThread { get; } + /// /// Executes the action on the UI thread asynchronously. /// diff --git a/src/Caliburn.Micro.Platform/Platforms/Android/AndroidPlatformProvider.cs b/src/Caliburn.Micro.Platform/Platforms/Android/AndroidPlatformProvider.cs index 62247046..53d6e7f4 100644 --- a/src/Caliburn.Micro.Platform/Platforms/Android/AndroidPlatformProvider.cs +++ b/src/Caliburn.Micro.Platform/Platforms/Android/AndroidPlatformProvider.cs @@ -20,7 +20,11 @@ public class AndroidPlatformProvider : IPlatformProvider public AndroidPlatformProvider(Application application) { application.RegisterActivityLifecycleCallbacks(lifecycleHandler); } - + + /// + /// Whether or not classes should execute property change notications on the UI thread. + /// + public virtual bool PropertyChangeNotificationsOnUIThread => true; private bool CheckAccess() { return SynchronizationContext.Current != null; diff --git a/src/Caliburn.Micro.Platform/Platforms/Xamarin.Forms/FormsPlatformProvider.cs b/src/Caliburn.Micro.Platform/Platforms/Xamarin.Forms/FormsPlatformProvider.cs index 32492df0..1b93bae6 100644 --- a/src/Caliburn.Micro.Platform/Platforms/Xamarin.Forms/FormsPlatformProvider.cs +++ b/src/Caliburn.Micro.Platform/Platforms/Xamarin.Forms/FormsPlatformProvider.cs @@ -24,6 +24,11 @@ public FormsPlatformProvider(IPlatformProvider platformProvider) { /// public virtual bool InDesignMode => platformProvider.InDesignMode; + /// + /// Whether or not classes should execute property change notications on the UI thread. + /// + public virtual bool PropertyChangeNotificationsOnUIThread => platformProvider.PropertyChangeNotificationsOnUIThread; + /// public virtual void BeginOnUIThread(System.Action action) => platformProvider.BeginOnUIThread(action); diff --git a/src/Caliburn.Micro.Platform/Platforms/iOS/iOSPlatformProvider.cs b/src/Caliburn.Micro.Platform/Platforms/iOS/iOSPlatformProvider.cs index 776c0dac..589b3615 100644 --- a/src/Caliburn.Micro.Platform/Platforms/iOS/iOSPlatformProvider.cs +++ b/src/Caliburn.Micro.Platform/Platforms/iOS/iOSPlatformProvider.cs @@ -24,6 +24,11 @@ public virtual bool InDesignMode get { return false; } } + /// + /// Whether or not classes should execute property change notications on the UI thread. + /// + public virtual bool PropertyChangeNotificationsOnUIThread => true; + /// /// Executes the action on the UI thread asynchronously. /// diff --git a/src/Caliburn.Micro.Platform/XamlPlatformProvider.cs b/src/Caliburn.Micro.Platform/XamlPlatformProvider.cs index e4c0aa1b..4b3c7c37 100644 --- a/src/Caliburn.Micro.Platform/XamlPlatformProvider.cs +++ b/src/Caliburn.Micro.Platform/XamlPlatformProvider.cs @@ -33,6 +33,11 @@ public XamlPlatformProvider() { #endif } + /// + /// Whether or not classes should execute property change notications on the UI thread. + /// + public virtual bool PropertyChangeNotificationsOnUIThread => true; + /// /// Indicates whether or not the framework is in design-time mode. ///