当前位置: 首页>>代码示例>>C#>>正文


C# ScheduledTask类代码示例

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


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

示例1: OnInvoke

        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            var tile = (from t in ShellTile.ActiveTiles select t).FirstOrDefault();
            var common = new Common();
            var startHour = new DateTime(2014, 05, 13, 08, 50, 00).Hour;
            var startMinute = new DateTime(2014, 05, 13, 08, 50, 00).Minute;
            var currentHour = DateTime.Now.Hour;
            var currentMinute = DateTime.Now.Minute;
            var callReport = (currentHour == startHour && currentMinute >= startMinute) || currentHour >= startHour;
            if (callReport)
            {
                var isUpdated = common.IsUpdated();

                if (tile != null && isUpdated.Result)
                {
                    var newTile = new IconicTileData
                        {
                            Count = 1
                        };
                    tile.Update(newTile);
                }
            }

            // Call NotifyComplete to let the system know the agent is done working.
            NotifyComplete();
        }
开发者ID:codermee,项目名称:pollenkoll,代码行数:35,代码来源:ScheduledAgent.cs

示例2: OnInvoke

        /// <summary>
        /// 运行计划任务的代理
        /// </summary>
        /// <param name="task">
        /// 调用的任务
        /// </param>
        /// <remarks>
        /// 调用定期或资源密集型任务时调用此方法
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            string taskType="";
            //TODO: 添加用于在后台执行任务的代码
            if (task is PeriodicTask)
                taskType = "PeriodicTask";
            if (task is ResourceIntensiveTask)
                taskType = "ResourceIntensiveTask";

            ShellToast shellToast = new ShellToast();
            shellToast.Title = taskType;
            shellToast.Content = "测试";
            shellToast.NavigationUri=new System.Uri("/MainPage.xaml?taskType="+taskType, System.UriKind.Relative);
            shellToast.Show();

            ShellTile shellTile=ShellTile.ActiveTiles.First();
            shellTile.Update
                (new StandardTileData{
             Count=5
                } );

            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(15));

            NotifyComplete(); 
        }
开发者ID:peepo3663,项目名称:WindowsPhone8,代码行数:34,代码来源:ScheduledAgent.cs

示例3: OnInvoke

        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            if (FBDataAccess.Current.IsLoggedIn())
            {
                // wait handler for the end of task processing
                var lcklist = new List<ManualResetEvent>();

                // toast notifications
                lcklist.Add(NotifyLatestNotifications(task.LastScheduledTime));

                // update live tiles
                var tileMapping = new Dictionary<string, ShellTile>(); // user id, tile
                for (int i = 0; i < ShellTile.ActiveTiles.Count(); i++)
                {
                    var tile = ShellTile.ActiveTiles.ElementAt(i);
                    var id = i == 0 ? "me" : tile.NavigationUri.GetQueryString("id");
                    tileMapping.Add(id, tile);
                }
                foreach (var tilemap in tileMapping)
                {
                    lcklist.Add(UpdateUserLiveTile(tilemap.Key, tilemap.Value));
                }

                // wait for the handler
                foreach (var lck in lcklist)
                {
                    lck.WaitOne();
                }
            }

            // Call NotifyComplete to let the system know the agent is done working.
            NotifyComplete();
        }
开发者ID:mvalipour,项目名称:WP7Facefeed,代码行数:42,代码来源:NotificationTask.cs

示例4: OnInvoke

        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        //protected override void OnInvoke(ScheduledTask task)
        //{
        //    //TODO: Add code to perform your task in background
        //    NotifyComplete();
        //}
        protected override void OnInvoke(ScheduledTask task)
        {
            // some random number
            Random random = new Random();
            // get application tile
            ShellTile tile = ShellTile.ActiveTiles.First();
            if (null != tile)
            {
                // creata a new data for tile
                StandardTileData data = new StandardTileData();
                // tile foreground data
                data.Title = "Title text here";
                data.BackgroundImage = new Uri("/Images/Blue.jpg", UriKind.Relative);
                data.Count = random.Next(99);
                // to make tile flip add data to background also
                data.BackTitle = "Secret text here";
                data.BackBackgroundImage = new Uri("/Images/Green.jpg", UriKind.Relative);
                data.BackContent = "Back Content Text here...";
                // update tile
                tile.Update(data);
            }
            #if DEBUG_AGENT
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(30));
            System.Diagnostics.Debug.WriteLine("Periodic task is started again: " + task.Name);
            #endif

            NotifyComplete();
        }
开发者ID:Nordic-T,项目名称:Nordic-T-WP,代码行数:42,代码来源:ScheduledAgent.cs

示例5: FireExitingTask

        public void FireExitingTask(ScheduledTask scheduledTask)
        {
            var jobKey = scheduledTask.GetJob().Key;

            if (_scheduler.CheckExists(jobKey))
                _scheduler.TriggerJob(jobKey);
        }
开发者ID:mamluka,项目名称:SpeedyMailer,代码行数:7,代码来源:ScheduledTaskManager.cs

示例6: OnInvoke

        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {

            string toastMessage;

            if(task is PeriodicTask)
            {

                toastMessage = "Periodic task running.";

            }
            else
            {
                toastMessage = "Resource-intensive task running.";
            }

            var toast = new ShellToast {Title = "Background Agent Sample", Content = toastMessage};

            toast.Show();

#if DEBUG_AGENT

            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds((60)));

#endif

            NotifyComplete();
        }
开发者ID:IgorCandido,项目名称:NodeTests,代码行数:37,代码来源:ScheduledAgent.cs

示例7: OnInvoke

        protected override void OnInvoke(ScheduledTask task)
        {
            if (LockScreenManager.IsProvidedByCurrentApplication)
            {
                try
                {
                    var currentImage = LockScreen.GetImageUri();
                    string Imagename = string.Empty;
                    IsolatedStorageFile isoStorageFile = IsolatedStorageFile.GetUserStoreForApplication();
                    string[] totalImags = isoStorageFile.GetFileNames("/Shared/ShellContent/");
                    

                    string imgCount = currentImage.ToString().Substring(currentImage.ToString().IndexOf('_') + 1, currentImage.ToString().Length - (currentImage.ToString().IndexOf('_') + 1)).Replace(".jpg", "");
                    Random miIdRand = new Random();
                    Imagename = string.Format("Img{0}.jpg", miIdRand.Next(1, totalImags.Length));
                    LockScreenChange(Imagename);

                    //ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(5));
                    Thread.Sleep(6000);
                    OnInvoke(task);
                }
                catch
                {
                    NotifyComplete();
                }
            }
            else
            {
                
                ScheduledActionService.Remove(task.Name);
            }            
        }
开发者ID:rubone,项目名称:wp.photodisplay,代码行数:32,代码来源:ScheduledAgent.cs

示例8: AddTask

        public ActionResult AddTask(string name = "", string runtime = "", int interval = 0,string url = "")
        {
            try {
                if (url.Trim() == "") {
                    throw new Exception("Task must have a path.");
                }
                if (runtime.Trim() == "" && interval < 1) {
                    throw new Exception("Task must have a run time or an interval greater than 5 minutes.");
                }

                ScheduledTask s = new ScheduledTask {
                    name = name,
                    url = url
                };
                if (runtime.Trim() != "") {
                    DateTime rtime = Convert.ToDateTime(runtime).ToUniversalTime();
                    s.runtime = rtime;
                } else if(interval > 1) {
                    s.interval = interval;
                }
                EcommercePlatformDataContext db = new EcommercePlatformDataContext();
                db.ScheduledTasks.InsertOnSubmit(s);
                db.SubmitChanges();
            } catch {}
            return RedirectToAction("index");
        }
开发者ID:meganmcchesney,项目名称:CURTeCommerce,代码行数:26,代码来源:SchedulerController.cs

示例9: OnInvoke

        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {

            //TODO: Add code to perform your task in background

            /// If application uses both PeriodicTask and ResourceIntensiveTask
            if (task is PeriodicTask)
            {
                // Execute periodic task actions here.
                ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("TileID=2"));
                if (TileToFind != null)
                {
                     StandardTileData NewTileData = new StandardTileData
                        {
                            Title= "updated by scheduled task",
                            Count = System.DateTime.Now.Minute
                        };
                     TileToFind.Update(NewTileData);
                }
            }
            else
            {
                // Execute resource-intensive task actions here.
            }

            NotifyComplete();
           
        }
开发者ID:fstn,项目名称:WindowsPhoneApps,代码行数:37,代码来源:TaskScheduler.cs

示例10: OnInvoke

        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            specifics = task.Description.Split(new string[] { "split" }, StringSplitOptions.None);
            StartHour = int.Parse(specifics[0]);
            StartMin = int.Parse(specifics[1]);
            LateHour = int.Parse(specifics[2]);
            LateMin = int.Parse(specifics[3]);
            Tune = specifics[4];
            DateTime LateAlarmTime = new DateTime(2013, 1, 1, LateHour, LateMin, 0);
            IEnumerable<ScheduledNotification> notifications = ScheduledActionService.GetActions<ScheduledNotification>();
            AlarmsSet = 0;
            if (notifications != null)
            {
                for (int i = 0; i < notifications.Count(); i++)
                {
                    if (notifications.ElementAt(i).ExpirationTime.TimeOfDay > notifications.ElementAt(i).BeginTime.AddSeconds(1).TimeOfDay && notifications.ElementAt(i).ExpirationTime.TimeOfDay < notifications.ElementAt(i).BeginTime.AddSeconds(5).TimeOfDay && notifications.ElementAt(i).BeginTime.TimeOfDay < LateAlarmTime.TimeOfDay)
                    {
                        AlarmsSet++;
                    }
                }
            }

            Appointments appts = new Appointments();

            appts.SearchCompleted += new EventHandler<AppointmentsSearchEventArgs>(Appointments_SearchCompleted_Background);

            DateTime start = DateTime.Now;
            start = start.AddHours(-start.Hour);
            start = start.AddMinutes(-start.Minute);
            DateTime end = DateTime.Now.AddDays(7);

            appts.SearchAsync(start, end, "Appointments Test #1");
        }
开发者ID:JStonevalley,项目名称:AutoAlarm,代码行数:42,代码来源:ScheduledAgent.cs

示例11: OnInvoke

        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            //TODO: Add code to perform your task in background

            string toastMessage = "";

            // If your application uses both PeriodicTask and ResourceIntensiveTask
            // you can branch your application code here. Otherwise, you don't need to.
            if (task is PeriodicTask)
            {
                // Execute periodic task actions here.
                toastMessage = "Periodic task running.";
            }
            else
            {  
                // Execute resource-intensive task actions here.
                toastMessage = "Resource-intensive task running.";
            }

            // Launch a toast to show that the agent is running.
            // The toast will not be shown if the foreground application is running.
            ShellToast toast = new ShellToast();
            toast.Title = "Background Agent Sample";
            toast.Content = toastMessage;
            toast.Show();

            // If debugging is enabled, launch the agent again in one minute.
            #if DEBUG_AGENT
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
            #endif

            // Call NotifyComplete to let the system know the agent is done working.
            NotifyComplete();
        }
开发者ID:dmourainatel,项目名称:Windows-Phone-Projects,代码行数:43,代码来源:ScheduledAgent.cs

示例12: OnInvoke

        /// <summary>
        ///     Method called when PeriodicTask is invoked.
        /// </summary>
        /// <param name="task">Periodic task invoked.</param>
        protected override void OnInvoke(ScheduledTask task)
        {
            if (!new SettingsController().CatURLExists())
            {
                // Cat URL doesn't exist, so parse RSS.
                this.ParseRSSFeed();
            }
            else
            {
                // Cat URL exists, so perform date check.
                SettingsController settingsController = new SettingsController();

                if (settingsController.LastUpdatedExists())
                {
                    // lastUpdated setting exists, so check.
                    DateTime lastUpdated = new SettingsController().GetLastUpdated();
                    DateTime now = DateTime.Now;

                    if (lastUpdated.Date.CompareTo(now.Date) < 0)
                    {
                        // lastUpdated date is before Today, so parse RSS Feed to get a new image.
                        this.ParseRSSFeed();
                    }
                }
                else
                {
                    // lastUpdated setting doesn't exist, so parse RSS.
                    this.ParseRSSFeed();
                }
            }
        }
开发者ID:JonJam,项目名称:lolcatcalendar,代码行数:35,代码来源:ScheduledAgent.cs

示例13: OnInvoke

        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            // TODO: see when last prompted & if time for next prompt

            var data = new MainViewModel();

            var nextLesson = data.Lessons.FirstOrDefault(l => !l.Completed);

            var toast = new ShellToast
            {
                Title = "Time for",
                Content = nextLesson.Name
            };
            toast.Show();

            var mainTile = ShellTile.ActiveTiles.First();

            mainTile.Update(new IconicTileData
            {
                WideContent1 = "Time for more",
                WideContent2 = "watch " + nextLesson.Name
            });

            #if DEBUG
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
            #endif

            NotifyComplete();
        }
开发者ID:ramhemasri,项目名称:Pusher,代码行数:38,代码来源:ScheduledAgent.cs

示例14: OnInvoke

 /// <summary>
 /// Agent zum Ausführen einer geplanten Aufgabe
 /// </summary>
 /// <param name="task">
 /// Die aufgerufene Aufgabe
 /// </param>
 /// <remarks>
 /// Diese Methode wird aufgerufen, wenn eine regelmäßige oder ressourcenintensive Aufgabe aufgerufen wird
 /// </remarks>
 protected override void OnInvoke(ScheduledTask task)
 {
     _curTask = task;
     //TODO: Code zum Ausführen der Aufgabe im Hintergrund hinzufügen
     if (_settingsFile.Contains("mode") != true)
     {
         NotifyComplete();
     }
     if ((int)_settingsFile["mode"] == 0) {
         _dayStr = " heute ";
     }
     else if ((int)_settingsFile["mode"] == 1)
     {
         _dayStr = " morgen ";
     }
     _fetcher = new Fetcher((int)_settingsFile["mode"]);
     _fetcher.RaiseErrorMessage += (sender, e) =>
     {
         Stop();
     };
     _fetcher.RaiseRetreivedScheduleItems += (sender, e) =>
     {
         Proceed(e.Schedule);
     };
     if (_settingsFile.Contains("group"))
     {
         _fetcher.GetTimes((int)_settingsFile["group"] + 1);
     }
     else
     {
         Stop();
     }
 }
开发者ID:reknih,项目名称:informant-wp,代码行数:42,代码来源:ScheduledAgent.cs

示例15: OnInvoke

        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            try
            {
                //TODO: Add code to perform your task in background
                // 更新应用程序磁贴
                int lastDay = task.LastScheduledTime.Day;
                int today = DateTime.Today.Day;

                if (task.LastScheduledTime.Year > 1 && today != lastDay)
                {
                    RefreshTile();
                }

                //toast
                // 弹出 Toast
                LoadSetting();
                DateTime now = DateTime.Now;
                if (now.TimeOfDay.CompareTo(ALARM_TIME.TimeOfDay) >= 0 //alarm time is arrived  .fix on 2013-6-1, add "time of the day"
                    && !HASALARMED //alarm is not triggered today
                    && ALARM_SWITCH //alarm is on
                    && (ALARM_THRESHOLD + LEFTGLASSES > 8)) //threshold is not reached
                    //if (now.TimeOfDay.CompareTo(ALARM_TIME.TimeOfDay) >= 0  && ALARM_SWITCH && (ALARM_THRESHOLD + LEFTGLASSES > 8))  //for TEST
                {
                    ShowToast();
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                NotifyComplete();
            }
        }
开发者ID:juyingnan,项目名称:VS,代码行数:44,代码来源:ScheduledAgent.cs


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