Sample Windows 8 C# app

skeleton.app.cs
 
        public App()
        {
            this.InitializeComponent();
            this.Suspending += new SuspendingEventHandler(OnSuspending);
            this.Resuming += new EventHandler(OnResuming);
        }
 
        async void OnSuspending(object sender, SuspendingEventArgs args)
        {
            SuspendingDeferral deferral = args.SuspendingOperation.GetDeferral();
            await SuspensionManager.SaveAsync();
            appSession.Close();
            appSession.Upload();
            deferral.Complete();
        }
 
        void OnResuming(object sender, Object args)
        {
            appSession.Open();
            appSession.Upload();
        }
 
 
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// Details about the launch request and process.
        async protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            appSession = new LocalyticsSession("YOUR APP KEY GOES HERE");.
            appSession.Open();
            appSession.Upload();
 
            this.LaunchArgs = args;
 
            Frame rootFrame = null;
            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                // Do an asynchronous restore
                await SuspensionManager.RestoreAsync();
            }
            if (Window.Current.Content == null)
            {
                rootFrame = new Frame();
                rootFrame.Navigate(typeof(MainPage));
                //SuspensionManager.RegisterFrame(rootFrame, "appFrame");
                Window.Current.Content = rootFrame;
            }
            Window.Current.Activate();
        }
    }