public async void Run(IBackgroundTaskInstance taskInstance)
 {
     try {
         new BackgroundTaskViewModelLocator();
         RecurringTransactionLogic.CheckRecurringTransactions();
         await TransactionLogic.ClearTransactions();
     }
     catch (Exception ex) {
         InsightHelper.Report(ex);
     }
 }
Example #2
0
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (!Insights.IsInitialized)
            {
                Insights.Initialize("599ff6bfdc79368ff3d5f5629a57c995fe93352e");
            }
#endif
            await ServiceLocator.Current.GetInstance <LicenseManager>().CheckLicenceFeaturepack();

            var 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 {
                    CacheSize = 1
                };

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Load state from previously suspended application
                }

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

            if (rootFrame.Content == null)
            {
#if WINDOWS_PHONE_APP
                // Removes the turnstile navigation for startup.
                if (rootFrame.ContentTransitions != null)
                {
                    transitions = new TransitionCollection();
                    foreach (Transition c in rootFrame.ContentTransitions)
                    {
                        transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated         += RootFrame_FirstNavigated;
#endif

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
            TileHelper.DoNavigation(e.TileId);

            RecurringTransactionLogic.CheckRecurringTransactions();
            await TransactionLogic.ClearTransactions();

            BackgroundTaskLogic.RegisterBackgroundTask();

            Tile.UpdateMainTile();
        }