using System;
using System.ComponentModel;
using System.Linq;
+using System.Threading;
using Android.App;
using Android.Content;
using Android.Content.Res;
using Android.Runtime;
using Android.Support.V7.App;
using Android.Views;
-using Android.Widget;
using Xamarin.Forms.Platform.Android.AppCompat;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific.AppCompat;
bool _activityCreated;
PowerSaveModeBroadcastReceiver _powerSaveModeBroadcastReceiver;
+ static readonly ManualResetEventSlim PreviousActivityDestroying = new ManualResetEventSlim(true);
+
// Override this if you want to handle the default Android behavior of restoring fragments on an application restart
protected virtual bool AllowFragmentRestore => false;
application.PropertyChanged += AppOnPropertyChanged;
+ // Wait if old activity destroying is not finished
+ PreviousActivityDestroying.Wait();
+
Profile.FramePartition(nameof(SetMainPage));
SetMainPage();
protected override void OnDestroy()
{
+ PreviousActivityDestroying.Reset();
+
if (_application != null)
_application.PropertyChanged -= AppOnPropertyChanged;
Platform?.Dispose();
+ PreviousActivityDestroying.Set();
+
// call at the end to avoid race conditions with Platform dispose
base.OnDestroy();
}