예제 #1
0
        public async Task SuspendAsync(ISuspendingDeferral deferral)
        {
            this.LogInfo($"Settings.AutoSuspend: {Settings.AutoSuspend} Settings.AutoExtendExecution: {Settings.AutoExtendExecution}");

            try
            {
                if (!Settings.AutoSuspend)
                {
                    return;
                }
                else if (Settings.AutoExtendExecution)
                {
                    using (var session = CreateSession())
                    {
                        foreach (var nav in ViewService.AllNavigationServices)
                        {
                            await nav.SuspendAsync();
                        }
                    }
                }
                else
                {
                    foreach (var nav in ViewService.AllNavigationServices)
                    {
                        await nav.SuspendAsync();
                    }
                }
            }
            finally
            {
                deferral?.Complete();
            }
        }
예제 #2
0
        public async Task SuspendAsync(ISuspendingDeferral deferral)
        {
            this.LogInfo($"Settings.AutoSuspend: {Settings.AutoSuspend} Settings.AutoExtendExecution: {Settings.AutoExtendExecution}");

            try
            {
                if (!Settings.AutoSuspend)
                {
                    return;
                }
                else if (Settings.AutoExtendExecution)
                {
                    using (var session = CreateSession())
                    {
                        foreach (var nav in ViewService.AllNavigationServices)
                        {
                            await nav.SuspendAsync();
                        }
                    }
                }
                else
                {
                    foreach (var nav in ViewService.AllNavigationServices)
                    {
                        await nav.SuspendAsync();
                    }
                }
            }
            finally
            {
                deferral?.Complete();
            }
        }
예제 #3
0
        // *** Protected Methods ***

        protected async void OnSuspending(object sender, ISuspendingEventArgs e)
        {
            ISuspendingDeferral deferal = GetDeferral(e);

            IEnumerable <Task> resumingTasks = registeredServices.Select(service => service.OnSuspending());
            await Task.WhenAll(resumingTasks);

            deferal.Complete();
        }
예제 #4
0
 /// <summary>
 /// Runs a function while also getting a suspension deferral from the Windows Runtime.
 /// </summary>
 private static Func <Func <Task>, Task> RunWithDeferral(ISuspendingEventArgs e)
 {
     return(async function =>
     {
         ISuspendingDeferral deferral = e.SuspendingOperation.GetDeferral();
         try
         {
             await function();
         }
         finally
         {
             deferral.Complete();
         }
     });
 }