Esempio n. 1
0
 public void SuspendExecutors()
 {
     _log.Info("SuspendExecutors");
     if (OnSuspending != null)
     {
         foreach (Action handler in OnSuspending.GetInvocationList())
         {
             handler();
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// note: Suspending event will not fire during debugging. But sometimes it does.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void SuspendingAsync(object sender, SuspendingEventArgs args)
        {
            Debug.LogMessage("App.SuspendingAsync");
            // save app state asynchronously after requesting a deferral. Holding a deferral indicates that the application is busy
            // performing suspending operations. Be aware that a deferral may not be held indefinitely. After about five seconds,
            // the app will be forced to exit.
            SuspendingDeferral deferral = args.SuspendingOperation.GetDeferral();

            await Task.Run(() =>
            {
                // stop any running processes...

                OnSuspending?.Invoke(this, null);
            });

            deferral.Complete();
            CoreApplication.Exit();
#if DEBUG
            System.Diagnostics.Debug.WriteLine("App.SuspendingAsync() complete.");
#endif
        }