protected override async void OnLaunched()

in FamilyNotes/App.xaml.cs [82:135]


        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;
                
                if (args.PreviousExecutionState != ApplicationExecutionState.Running &&
                    args.PreviousExecutionState != ApplicationExecutionState.Suspended)
                {
                    await LoadModelAndSettingsAsync();
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), args.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();

            // Cortana voice commands.
            // Install Voice Command Definition (VCD) file.
            try
            {
                // Install the main VCD on launch to ensure 
                // most recent version is installed.
                StorageFile vcdStorageFile =
                    await Package.Current.InstalledLocation.GetFileAsync(
                        @"VoiceCommandObjects\VoiceCommands.xml");

                await Windows.ApplicationModel.
                    VoiceCommands.VoiceCommandDefinitionManager.
                    InstallCommandDefinitionsFromStorageFileAsync(
                    vcdStorageFile);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(
                    "Installing Voice Commands Failed: " + ex.ToString());
            }
        }