示例#1
0
        private async void ExecuteUpdateTileCommand(string value)
        {
            try
            {
                Busy = true;

                var number = default(int);
                if (!int.TryParse(value, out number))
                {
                    return;
                }
                await Task.Delay(2000);

                var trigger = new ApplicationTrigger();
                var task    = await BackgroundHelper.Register <MyUpdateBadgeTask>(trigger);

                task.Completed += (s, e) => { Busy = false; };

                var allowed = await trigger.RequestAsync();

                if (allowed != ApplicationTriggerResult.Allowed)
                {
                    // it was not allowed to run
                    Busy = false;
                }
            }
            catch { Busy = false; }
        }
示例#2
0
        public override async void OnNavigatedTo(string parameter, NavigationMode mode, Dictionary <string, object> state)
        {
            LoadCommand.Execute(null);

            // register background tasks
            await BackgroundHelper.Register <MyUpdateTileTask>(new SystemTrigger(SystemTriggerType.TimeZoneChange, false));
        }
示例#3
0
        private async void DismissExtendedSplash()
        {
            Window.Current.SizeChanged -= ExtendedSplash_OnResize;
            StateText = "正在检查后台通知";
            await BackgroundHelper.Register <UpdateUnreadCountTask>(new TimeTrigger(15, false));

            await BackgroundHelper.Register <ToastNotificationBackgroundTask>(new ToastNotificationActionTrigger());

            StateText = "正在初始化表情";
            await StaticResource.InitEmotion();

            var cahcesize = rootFrame.CacheSize;

            rootFrame.CacheSize = 0;
            rootFrame.CacheSize = cahcesize;
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            StateText = "正在初始化用户数据";
            if (await StaticResource.CheckForLogin())
            {
                await InitUid();

                rootFrame.Navigate(typeof(MainPage));
            }
            else
            {
                rootFrame.Navigate(typeof(LoginPage));
            }
            SystemNavigationManager.GetForCurrentView().BackRequested += ExtendedSplash_BackRequested;
            rootFrame.Navigated   += RootFrame_Navigated;
            Window.Current.Content = rootFrame;
        }
示例#4
0
        private async void RegisterBGTask_Click(object sender, RoutedEventArgs e)
        {
            var existing = BackgroundHelper.FindRegistration <OOPBackgroundTask.BadgeTask>();

            if (existing == null)
            {
                // await BackgroundHelper.Register<OOPBackgroundTask.BadgeTask>(new ToastNotificationActionTrigger());
                await BackgroundHelper.Register <OOPBackgroundTask.BadgeTask>(new TimeTrigger(15, false));
            }
            BGTaskList.Text = "";
            foreach (var t in BackgroundTaskRegistration.AllTasks)
            {
                BGTaskList.Text += t.Value.ToString() + "\n";
            }
        }