// *** Protected Methods ***

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

            await SuspendServicesAsync();

            deferal.Complete();
        }
示例#2
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();
        }
示例#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();
         }
     });
 }
 /// <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();
         }
     };
 }
示例#6
0
        public async Task SuspendAsync(ISuspendingEventArgs e)
        {
            Navigation.Settings.LastSuspended = DateTime.Now;

            if (Settings.EnableLifecycleStrategy)
            {
                PreviouslySuspended = true;

                _messengerService.Send(new Messages.SuspendingMessage {
                    EventArgs = e
                });

                // TODO: what to do with multiple views?

                foreach (var nav in NavigationService.Instances.Select(x => x as INavigationService2))
                {
                    await nav.SaveAsync(true);
                }
            }
        }
        protected virtual ISuspendingDeferral GetDeferral(ISuspendingEventArgs e)
        {
            // NB: Use a virtual method rather than getting the deferral directly to aid testing

            return e.SuspendingOperation.GetDeferral();
        }
示例#8
0
        protected virtual ISuspendingDeferral GetDeferral(ISuspendingEventArgs e)
        {
            // NB: Use a virtual method rather than getting the deferral directly to aid testing

            return(e.SuspendingOperation.GetDeferral());
        }
 protected override ISuspendingDeferral GetDeferral(ISuspendingEventArgs e)
 {
     return ((MockSuspendingEventArgs)e).GetDeferral();
 }
示例#10
0
        }                                                                  // Noncompliant

        private async void OnSuspending(object sender, ISuspendingEventArgs e)
        {
        }                                                                          // Compliant - ends with EventArgs and 1st param is object sender
示例#11
0
 private async void OnSuspending(object sender, ISuspendingEventArgs e)
 {
 }
示例#12
0
 async void MyOtherMethod1(object o, ISuspendingEventArgs args)
 {
 }
示例#13
0
            // *** Overriden base methods ***

            protected override ISuspendingDeferral GetDeferral(ISuspendingEventArgs e)
            {
                return(((MockSuspendingEventArgs)e).GetDeferral());
            }
示例#14
0
            // *** Methods ***

            public void Suspend(ISuspendingEventArgs e)
            {
                base.OnSuspending(null, e);
            }
示例#15
0
 async void MyOtherMethod1(object o, ISuspendingEventArgs args)
 {
     await Task.Run(() => Console.WriteLine("test"));
 }
示例#16
0
 private async void OnSuspending(object sender, ISuspendingEventArgs e)
 {
     await Task.Run(() => Console.WriteLine("test"));
 }
示例#17
0
 public void Suspend(ISuspendingEventArgs e)
 {
     base.OnSuspending(null, e);
 }