예제 #1
0
        // *** 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);
                }
            }
        }
예제 #7
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();
        }
예제 #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());
        }
예제 #9
0
 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);
 }