/// <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)
        {
            // Track App suspension/exit:
            GlobalStopwatch.Stop();
            TelemetryHelper.TrackMetric("AppRuntime", GlobalStopwatch.Elapsed.TotalMilliseconds);

            var metrics = new Dictionary <string, string> {
                { "appRuntime", GlobalStopwatch.Elapsed.TotalMilliseconds.ToString() }
            };

            TelemetryHelper.TrackEvent("UserRuntime", metrics);

            var deferral = e.SuspendingOperation.GetDeferral();

            //TODO: Save application state and stop any background activity
            deferral.Complete();
        }
        /// <summary>
        /// Invoked when the heartbeat timer ticks.
        /// </summary>
        void HeartbeatTimer_Tick(object sender, object e)
        {
            // Log telemetry event that the device is alive

            TelemetryHelper.TrackMetric("DeviceHeartbeat", heartbeatInterval);
        }