Exemplo n.º 1
0
        /// <summary>
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// </summary>
        /// <param name="sender">The source of the suspend request.</param>
        /// <param name="e">Details about the suspend request.</param>
        private void OnSuspending(object sender, SuspendingEventArgs e)
        {
            SuspendingDeferral deferral = e.SuspendingOperation.GetDeferral();

            MetroEventSource.ToastAsync("Shokpod suspended!");
            deferral.Complete();
        }
Exemplo n.º 2
0
        private async void BeginExtendedExecution()
        {
            ClearExtendedExecution();

            var newSession = new ExtendedExecutionSession
            {
                Reason      = ExtendedExecutionReason.Unspecified,
                Description = "Keep Shokpod running in background"
            };

            newSession.Revoked += ExtendedExecutionSession_RevokedAsync;
            ExtendedExecutionResult result = await newSession.RequestExtensionAsync();

            switch (result)
            {
            case ExtendedExecutionResult.Allowed:
                MetroEventSource.ToastAsync("Request for background execution granted!");
                extendedExecutionSession = newSession;
                break;

            default:
            case ExtendedExecutionResult.Denied:
                MetroEventSource.ToastAsync("Request for background execution denied!");
                newSession.Dispose();
                break;
            }
        }
 private void OnRecordingQueueEvent(object sender, RecordingQueue.RecordingQueueEventArgs e)
 {
     if (e.Record != null)
     {
         Debug("Persisted acceleration of " + e.Record.Value.Acceleration + "G.");
         MetroEventSource.ToastAsync("Persisted acceleration of " + e.Record.Value.Acceleration + "G.");
     }
     else if (e.Response != null)
     {
         Debug("HTTP call to the ShokPod remote server failed with error: '" + e.Response + ".'");
     }
     else if (e.Exception != null)
     {
         Debug("Exception while saving data to the remote server." + e.Exception.Message);
     }
     else if (e.MaximumImpact != null)
     {
         Debug("Recording acceleration of " + e.MaximumImpact.Value.Acceleration + "G.");
     }
 }
Exemplo n.º 4
0
        private async void ExtendedExecutionSession_RevokedAsync(object sender, ExtendedExecutionRevokedEventArgs args)
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                switch (args.Reason)
                {
                case ExtendedExecutionRevokedReason.Resumed:
                    MetroEventSource.ToastAsync("Extended execution revoked due to returning to foreground.");
                    BeginExtendedExecution();
                    break;

                case ExtendedExecutionRevokedReason.SystemPolicy:
                    MetroEventSource.ToastAsync("Extended execution revoked due to system policy.");
                    ClearExtendedExecution();
                    break;

                default:
                    ClearExtendedExecution();
                    break;
                }
            });
        }