• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# PeriodicTask类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PeriodicTask的典型用法代码示例。如果您正苦于以下问题:C# PeriodicTask类的具体用法?C# PeriodicTask怎么用?C# PeriodicTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PeriodicTask类属于命名空间,在下文中一共展示了PeriodicTask类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PhoneApplicationPage_Loaded

 private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) {
     if(FirstLoad) {
         FirstLoad = false;
         MainPivot.SelectionChanged += MainPivot_SelectionChanged;
         if(NetworkInterface.GetIsNetworkAvailable()) {
             if((DataContext as Settings).ComicList.Count == 0) {
                 try {
                     (DataContext as Settings).ComicList.Add(await XkcdInterface.GetCurrentComic());
                     System.Diagnostics.Debug.WriteLine((DataContext as Settings).ComicList.Count);
                 } catch(WebException) {
                     ShowNotification("Comic couldn't be loaded", 4000);
                 }
             } else {
                 GetNewerComics();
             }
             if(ScheduledActionService.Find(BackgroundTaskName) == null) {
                 var task = new PeriodicTask(BackgroundTaskName) {
                     Description = "Gets the number of new comics from xkcd"
                 };
                 try {
                     ScheduledActionService.Add(task);
                 } catch(InvalidOperationException) { }
             }
         } else {
             ShowNotification(NoNetworkMessage, 4000);
         }
     }
 }
开发者ID:jonstodle,项目名称:wpcd,代码行数:28,代码来源:MainPage.xaml.cs


示例2: AddTask

 public static void AddTask(string taskName, string description)
 {
     RemoveTask(taskName);
     PeriodicTask task = new PeriodicTask(taskName);
     task.Description = description;
     ScheduledActionService.Add(task);
 }
开发者ID:ameerkat,项目名称:Simple-Weather,代码行数:7,代码来源:TaskHelper.cs


示例3: Task

 public Task()
 {
     periodicTask = ScheduledActionService.Find(periodicTaskName) as PeriodicTask;
     #if DEBUG
     if (periodicTask != null)
     {
         ScheduledActionService.Remove(periodicTaskName);
         periodicTask = null;
     }
     #endif
     if (periodicTask == null)
     {
         periodicTask = new PeriodicTask(periodicTaskName);
         periodicTask.Description = "Sparklr notification agent";
         try
         {
             ScheduledActionService.Add(periodicTask);
         }
         catch (Exception ex)
         {
             //TODO: Handle errors here (For example if there are too many background tasks already)
         }
     }
     // If debugging is enabled, use LaunchForTest to launch the agent in 15 seconds.
     #if DEBUG
     ScheduledActionService.LaunchForTest(periodicTaskName, new TimeSpan(0, 0, 15));
     #endif
 }
开发者ID:TheInterframe,项目名称:SparklrWP-OLD,代码行数:28,代码来源:Task.cs


示例4: OnNavigatedTo

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            // Display the default instructions.
            agentDetails.Text = defaultTaskDesc;

            // Find running periodic task.
            tilePeriodicTask = ScheduledActionService.Find(tileTaskName) as PeriodicTask;

            // Update the UI based on the running periodic task.
            if (toastPeriodicTask != null)
            {
                // Update the UI to display the currently running toast task info.
                PeriodicStackPanel.DataContext = toastPeriodicTask;
                TileRadioBtnOption.IsEnabled = false;
                startStopButton.Content = stopAgentString;
            }

            else if (tilePeriodicTask != null)
            {
                // Update the UI to display the currently running Tile task info.
                PeriodicStackPanel.DataContext = tilePeriodicTask;
                TileRadioBtnOption.IsChecked = true;
                TileRadioBtnOption.IsEnabled = false;
                startStopButton.Content = stopAgentString;
                agentDetails.Text = tileAgentDetails;
            }
            else
            {
                // No running task is running. Select Tile radio button.
                TileRadioBtnOption.IsChecked = true;
            }
        }
开发者ID:sikyurabmt,项目名称:HQL,代码行数:32,代码来源:MainPage.xaml.cs


示例5: PeriodicTileUpdater

        public static void PeriodicTileUpdater()
        {
            var periodicTask = ScheduledActionService.Find(TaskName) as PeriodicTask;

            if ( periodicTask != null )
            {
                ScheduledActionService.Remove(TaskName);
            }

            periodicTask = new PeriodicTask(TaskName)
            {
                Description = "Periodic Task to Update the ApplicationTile"
            };

            // Place the call to Add in a try block in case the user has disabled agents.
            try
            {
                ScheduledActionService.Add(periodicTask);

                // If debugging is enabled, use LaunchForTest to launch the agent in one minute.
                //ScheduledActionService.LaunchForTest(TaskName, TimeSpan.FromSeconds(10));
            }
            catch ( InvalidOperationException ex )
            {
                Debug.WriteLine(ex.Message);
            }
        }
开发者ID:Codealike,项目名称:Codealike-WinPhone,代码行数:27,代码来源:DashboardView.xaml.cs


示例6: StartTracking

        private void StartTracking()
        {
            string tileTaskId = "PodcastStarterKitPlaybackAudioAgent";

            tileTask = ScheduledActionService.Find(tileTaskId) as PeriodicTask;
            
            if (tileTask != null && !tileTask.IsEnabled)
            {
                MessageBox.Show("Background agent for this application has been disabled by the user.");
                return;
            }

            if (tileTask != null && tileTask.IsEnabled)
            {
                RemoveAgent(tileTaskId);
            }

            tileTask = new PeriodicTask(tileTaskId);

            tileTask.Description = "New Poscast Finder";
            ScheduledActionService.Add(tileTask);

         
            // If debugging is enabled, use LaunchForTest to launch the agent in one minute.
            #if(DEBUG)
            ScheduledActionService.LaunchForTest(tileTaskId, TimeSpan.FromSeconds(60));
            #endif
        }
开发者ID:juhariis,项目名称:Windows-Phone-Starter-Kit-for-Podcasts,代码行数:28,代码来源:MainPage.xaml.cs


示例7: Start

        /// <summary>
        /// 启动
        /// </summary>
        public static void Start()
        {
            if (!AppSetting.IsScheduledAgent)
            {
                return;
            }

            if (isAgentOn)
            {
                return;
            }
            Stop();

            var periodicTask = new PeriodicTask(Params.PeriodicTaskName);

            periodicTask.Description = "腾讯微博客户端Altman后台任务,用于帮助用户检查是否有新微博,您可以在应用设置选项中将其关闭或者在手机的后台任务界面停止它。";

            try
            {
                ScheduledActionService.Add(periodicTask);
                //ScheduledActionService.LaunchForTest(Common.Params.PeriodicTaskName, TimeSpan.FromSeconds(2));
                isAgentOn = true;
            }
            catch { isAgentOn = false; }
        }
开发者ID:chwzou,项目名称:WP7Fanfou,代码行数:28,代码来源:ScheduledHelper.cs


示例8: startStopButton_Click

        private void startStopButton_Click(object sender, RoutedEventArgs e)
        {
            // Find a reference to each of the two possibe periodic agents.
            tilePeriodicTask = ScheduledActionService.Find(tileTaskName) as PeriodicTask;

            // If either periodic agent is running, end it.
            // Otherwise, run the periodic agent based on the radio
            // button selection.
            if ((tilePeriodicTask != null))
            {

                // If the Tile periodic task is running, end it.
                if (tilePeriodicTask != null)
                {
                    RemoveAgent(tileTaskName);
                }
            }
            else
            {
                // Run the periodic agent based on the radio button selection.
                if ((bool)TileRadioBtnOption.IsChecked)
                {
                    StartPeriodicAgent(tileTaskName);
                    agentDetails.Text = tileAgentDetails;
                }
                else
                {
                    MessageBoxResult result = MessageBox.Show(startStopButtonMessage);
                }
            }
        }
开发者ID:sikyurabmt,项目名称:HQL,代码行数:31,代码来源:MainPage.xaml.cs


示例9: Application_Launching

        // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
            // A unique name for the task. 
            var taskName = "Contoso Cookbook Community Updates";

            // If the task exists
            var oldTask = ScheduledActionService.Find(taskName) as PeriodicTask;
            if (oldTask != null)
            {
                ScheduledActionService.Remove(taskName);
            }

            // Create the Task
            PeriodicTask task = new PeriodicTask(taskName);

            // Description is required
            task.Description = "This looks for data on recipes shared by your community on Contoso Cookbook";

            // Add it to the service to execute
            ScheduledActionService.Add(task);

            // For debugging
            ScheduledActionService.LaunchForTest(taskName,  TimeSpan.FromMilliseconds(5000));


        }
开发者ID:WindowsPhone-8-TrainingKit,项目名称:HOL-WPNotifications,代码行数:28,代码来源:App.xaml.cs


示例10: Button_Click_1

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string name="PeriodicTask";
            PeriodicTask periodicTask = ScheduledActionService.Find(name) as PeriodicTask;
            if (periodicTask == null)
            {
                periodicTask = new PeriodicTask(name);
            }
            else
            {
                ScheduledActionService.Remove(name);
                periodicTask = new PeriodicTask(name);
            }
            periodicTask.Description = "描述我们的PeriodicTask后台任务是干什么的"; 
            try
            {
                ScheduledActionService.Add(periodicTask);

                ScheduledActionService.LaunchForTest(name, TimeSpan.FromSeconds(1));
            }
            catch (InvalidOperationException ioe)
            {


            }


        }
开发者ID:peepo3663,项目名称:WindowsPhone8,代码行数:28,代码来源:MainPage.xaml.cs


示例11: StartPeriodicAgent

        public static void StartPeriodicAgent()
        {
            // Obtain a reference to the period task, if one exists
            var periodicTask = ScheduledActionService.Find(periodicTaskName) as PeriodicTask;

            // If the task already exists and background agents are enabled for the
            // application, you must remove the task and then add it again to update 
            // the schedule
            if (periodicTask != null)
            {
                RemoveAgent(periodicTaskName);
            }

            periodicTask = new PeriodicTask(periodicTaskName);

            // The description is required for periodic agents. This is the string that the user
            // will see in the background services Settings page on the device.
            periodicTask.Description = "换一下大瓷砖背面图片";

            // Place the call to Add in a try block in case the user has disabled agents.
            try
            {
                ScheduledActionService.Add(periodicTask);
#if DEBUG
                ScheduledActionService.LaunchForTest(periodicTaskName, TimeSpan.FromSeconds(60));
#endif

                GoogleAnalytics.EasyTracker.GetTracker().SendEvent("StartPeriodicAgent", "Result", "success", 1);
            }
            catch
            {
                UpdateTileScheduledTaskAgent.ScheduledAgent.ResetTile();
                GoogleAnalytics.EasyTracker.GetTracker().SendEvent("StartPeriodicAgent", "Result", "failure", 1);
            }
        }
开发者ID:oxcsnicho,项目名称:SanzaiGuokr,代码行数:35,代码来源:SaveTileImage.cs


示例12: StartPeriodicAgent

        public void StartPeriodicAgent()
        {
            agentsAreEnabled = true;
            periodicTask = ScheduledActionService.Find(periodicTaskName) as PeriodicTask;
            if (periodicTask != null)
            {
                RemoveAgent(periodicTaskName);
            }

            periodicTask = new PeriodicTask(periodicTaskName);
            periodicTask.Description = "This demonstrates a periodic task.";

            try
            {
                ScheduledActionService.Add(periodicTask);
                ScheduledActionService.LaunchForTest(periodicTaskName, TimeSpan.FromSeconds(20));
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("BNS Error: The action is disabled"))
                {
                    MessageBox.Show("Background agents for this application have been disabled by the user.");
                    agentsAreEnabled = false;
                }

                if (exception.Message.Contains("BNS Error: The maximum number of ScheduledActions of this type have already been added."))
                {
                    // No user action required. The system prompts the user when the hard limit of periodic tasks has been reached.
                }
            }
            catch (SchedulerServiceException)
            {
                // No user action required.
            }
        }
开发者ID:halllo,项目名称:DailyQuote,代码行数:35,代码来源:UpdateBackgroundAgent.cs


示例13: Application_Launching

        // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
            const string TASK_NAME = "GPS_TesteTask";
            var scheduleTask = ScheduledActionService.Find(TASK_NAME);
            if (scheduleTask == null)
            {
                scheduleTask = new PeriodicTask(TASK_NAME)
                {
                    Description = "Teste de GPS em background"
                };

                ScheduledActionService.Add(scheduleTask);
            }
            else if (scheduleTask.IsEnabled)
            {
                ScheduledActionService.Remove(TASK_NAME);
                ScheduledActionService.Add(scheduleTask);
            }

#if DEBUG
            ScheduledActionService.LaunchForTest(TASK_NAME, TimeSpan.FromSeconds(10));
#endif
            // inicializar o GPS uma vez na thread principal
            new GeoCoordinateWatcher(GeoPositionAccuracy.High).Start();
        }
开发者ID:tmenezes,项目名称:WindowsPhone.GpsBackground,代码行数:27,代码来源:App.xaml.cs


示例14: EnableLiveTileUpdateTask

        private void EnableLiveTileUpdateTask(object sender, RoutedEventArgs e)
        {
            _periodicTask = ScheduledActionService.Find(PeriodicTaskName) as PeriodicTask;

            if (_periodicTask != null)
            {
                RemoveAgent(PeriodicTaskName);
            }

            _periodicTask = new PeriodicTask(PeriodicTaskName);

            _periodicTask.Description = "JEVGENIDOTNET live tile update task";

            try
            {
                ScheduledActionService.Add(_periodicTask);

                #if DEBUG
                ScheduledActionService.LaunchForTest(PeriodicTaskName, TimeSpan.FromSeconds(30));
                #endif

                btnDisableLiveTileUpdate.IsEnabled = true;
                btnEnableLiveTileUpdate.IsEnabled = false;
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("BNS Error: The action is disabled"))
                {
                    MessageBox.Show("Background agents for this application have been disabled by the user.");
                }
            }
        }
开发者ID:SonLamUIT,项目名称:WPSamples,代码行数:32,代码来源:LiveTileUpdateSample.xaml.cs


示例15: AddBGTaks

        public static void AddBGTaks()
        {
            PeriodicTask periodicTask = new PeriodicTask("BF3Stats");
            periodicTask.Description = "Gets stats in background hourly";

            try
            {
                if (ScheduledActionService.Find(periodicTask.Name) != null)
                {
                    ScheduledActionService.Remove("BF3Stats");
                }
                ScheduledActionService.Add(periodicTask);
            }
            catch (InvalidOperationException ex)
            {
                if (ex.Message.Contains("BNS Error: The action is disabled"))
                {
                    MessageBox.Show("Background agents for this application have been disabled by the user.");
                }

                if (ex.Message.Contains("BNS Error: The maximum number of ScheduledActions of this type have already been added."))
                {
                    // No user action required. The system prompts the user when the hard limit of periodic tasks has been reached.
                }
            }

        }
开发者ID:graboskyc,项目名称:BFStats,代码行数:27,代码来源:BGTaks.cs


示例16: OnNavigatedTo

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            _periodicTask = ScheduledActionService.Find(PeriodicTaskName) as PeriodicTask;

            btnDisableLiveTileUpdate.IsEnabled = (_periodicTask != null);
            btnEnableLiveTileUpdate.IsEnabled = (_periodicTask == null);
        }
开发者ID:SonLamUIT,项目名称:WPSamples,代码行数:7,代码来源:LiveTileUpdateSample.xaml.cs


示例17: StartPeriodicAgent

 private void StartPeriodicAgent(int uid)
 {
     getUserNoticeTask = ScheduledActionService. Find( periodicTaskName ) as PeriodicTask;
     if ( getUserNoticeTask != null )
     {
         RemoveAgent( periodicTaskName );
     }
     getUserNoticeTask = new PeriodicTask( periodicTaskName );
     string cookie = TakeFromCookie( Config. Cookie );
     if ( cookie. IsNullOrWhitespace( ) )
     {
         return;
     }
     else
     {
         cookie = string. Format( "{0}@{1}", cookie, uid );
     }
     getUserNoticeTask. Description = cookie;
     try
     {
         ScheduledActionService. Add( getUserNoticeTask );
         ScheduledActionService. LaunchForTest( periodicTaskName, TimeSpan. FromMinutes( 20 ) );
     }
     catch ( InvalidOperationException exception )
     {
         if ( exception. Message. Contains( "BNS Error: The action is disabled" ) )
         {
             MessageBox. Show( "Background agents for this application have been disabled by the user." );
         }
     }
 }
开发者ID:haiger,项目名称:wp7-app,代码行数:31,代码来源:ScheduledUnit.cs


示例18: Add

        /// <summary>
        /// Call this to add the background task to update the live tile.
        /// </summary>
        /// <returns></returns>
        public static bool Add()
        {
            PeriodicTask periodicTask = new PeriodicTask(ShakingHelper.PeriodicTaskName);

            periodicTask.Description = AppResources.LiveTileTaskDescription;
            periodicTask.ExpirationTime = System.DateTime.Now.AddDays(14);

            // If the agent is already registered with the system,
            if (ScheduledActionService.Find(periodicTask.Name) != null)
            {
                ScheduledActionService.Remove(ShakingHelper.PeriodicTaskName);
            }

            //only can be called when application is running in foreground
            try
            {
                ScheduledActionService.Add(periodicTask);
            #if DEBUG
                ScheduledActionService.LaunchForTest(periodicTask.Name, TimeSpan.FromSeconds(60));
            #endif
            }
            catch (InvalidOperationException)
            {
                return false;
            }
            return true;
        }
开发者ID:adamsp,项目名称:wsnz-windowsphone,代码行数:31,代码来源:ScheduledTaskHelper.cs


示例19: StartTaskAgent

        public static void StartTaskAgent()
        {
            PeriodicTask task = 
                ScheduledActionService.Find(TaskName) as PeriodicTask;
            if (task != null)
            {
                RemoveAgent(TaskName);
            }

            task = new PeriodicTask(TaskName);
            task.Description = "Screen Tile description";

            try
            {
                ScheduledActionService.Add(task);

#if(DEBUG_AGENT)
                ScheduledActionService.LaunchForTest(TaskName, TimeSpan.FromSeconds(20));
#endif
            }
            catch (InvalidOperationException e)
            {
                Debug.WriteLine(e.Message);
            }
        }
开发者ID:SalmanRafiq,项目名称:MetroCalendar,代码行数:25,代码来源:TaskAgentUtilities.cs


示例20: CreatePeriodicTask

        public void CreatePeriodicTask(string name)
        {
            var task = new PeriodicTask(name)
                    {
                        Description = "Live tile updater for Weeker",
                        ExpirationTime = DateTime.Now.AddDays(14)
                    };

            // If the agent is already registered, remove it and then add it again
            RemovePeriodicTask(task.Name);

            try
            {
                // Can only be called when application is running in foreground
                ScheduledActionService.Add(task);
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("BNS Error: The action is disabled"))
                {
                    MessageBox.Show(Resource.BackgroundAgentsDisabled);
                }
                if (exception.Message.Contains("BNS Error: The maximum number of ScheduledActions of this type have already been added."))
                {
                    // No user action required.
                    // The system prompts the user when the hard limit of periodic tasks has been reached.
                }
            }
            #if DEBUG_AGENT
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
            #endif
        }
开发者ID:codermee,项目名称:weeker,代码行数:32,代码来源:TileUtility.cs



注:本文中的PeriodicTask类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Permission类代码示例发布时间:2022-05-24
下一篇:
C# Period类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap