private async Task InternalStartAsync(StartArgs startArgs)
        {
            await _startSemaphore.WaitAsync();

            if (_logStartingEvents)
            {
                _logger.Log($"{nameof(ApplicationTemplate)}.{nameof(InternalStartAsync)}({startArgs})", Category.Info, Priority.None);
            }

            // sometimes activation is rased through the base.onlaunch. We'll fix that.
            if (Interlocked.Increment(ref _started) > 1 && startArgs.StartKind == StartKinds.Launch)
            {
                startArgs.StartKind = StartKinds.Activate;
            }

            SetupExtendedSplashScreen();

            try
            {
                CallOnInitializedOnlyOnce();

                if (SuspensionUtilities.IsResuming(startArgs, out var resumeArgs))
                {
                    startArgs.StartKind = StartKinds.ResumeFromTerminate;
                    startArgs.Arguments = resumeArgs;
                }
                SuspensionUtilities.ClearSuspendDate();

                _logger.Log($"[App.OnStart(startKind:{startArgs.StartKind}, startCause:{startArgs.StartCause})]", Category.Info, Priority.None);
                OnStart(startArgs);

                _logger.Log($"[App.OnStartAsync(startKind:{startArgs.StartKind}, startCause:{startArgs.StartCause})]", Category.Info, Priority.None);
                await OnStartAsync(startArgs);
            }
            finally
            {
                _startSemaphore.Release();
            }

            void SetupExtendedSplashScreen()
            {
                if (startArgs.StartKind == StartKinds.Launch &&
                    startArgs.Arguments is IActivatedEventArgs act &&
                    Window.Current.Content is null &&
                    !(ExtendedSplashScreenFactory is null))
                {
                    try
                    {
                        Window.Current.Content = ExtendedSplashScreenFactory(act.SplashScreen);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception($"Error during {nameof(ExtendedSplashScreenFactory)}.", ex);
                    }
                }
            }
        }
        private async Task InternalStartAsync(StartArgs startArgs)
        {
            await _startSemaphore.WaitAsync();

            if (_logStartingEvents)
            {
                _logger.Log($"{nameof(ApplicationTemplate)}.{nameof(InternalStartAsync)}({startArgs})", Category.Info, Priority.None);
            }

            // sometimes activation is rased through the base.onlaunch. We'll fix that.
            if (Interlocked.Increment(ref _started) > 1 && startArgs.StartKind == StartKinds.Launch)
            {
                startArgs.StartKind = StartKinds.Activate;
            }

            try
            {
                CallOnInitializedOnlyOnce();

                if (SuspensionUtilities.IsResuming(startArgs, out var resumeArgs))
                {
                    startArgs.StartKind = StartKinds.ResumeFromTerminate;
                    startArgs.Arguments = resumeArgs;
                }
                SuspensionUtilities.ClearSuspendDate();

                _logger.Log($"[App.OnStart(startKind:{startArgs.StartKind}, startCause:{startArgs.StartCause})]", Category.Info, Priority.None);
                OnStart(startArgs);

                _logger.Log($"[App.OnStartAsync(startKind:{startArgs.StartKind}, startCause:{startArgs.StartCause})]", Category.Info, Priority.None);
                await OnStartAsync(startArgs);

                // this is redundant, but a friendly add-on
                Window.Current.Activate();
            }
            finally
            {
                _startSemaphore.Release();
            }
        }