Get the task and its status
- Get all tasks, using the following code:
C#
using System.Linq; using Telerik.Sitefinity.Scheduling; using Telerik.Sitefinity.Scheduling.Model; namespace SitefinityWebApp { public partial class TaskScheduleSnippets { public void GetAllTasks() { IQueryable<ScheduledTaskData> tasks = SchedulingManager.GetManager().GetTaskData(); } } } - To check if a task is running, using the
IsRunningproperty. - To set the task progress, use the following:
C#
using Telerik.Sitefinity.Scheduling; namespace SitefinityWebApp { public class MyCustomTask : ScheduledTask { public override void ExecuteTask() { // After you calculate the current progress of the task, just call the UpdateProgress method // No need to save the changes, or anything int progressPercent = 15; this.UpdateProgress(progressPercent); } } } - To retrieve the task progress, use the following code:
C#
using System.Linq; using Telerik.Sitefinity.Scheduling; public partial class ScheduleTaskSnippets { public void CheckTaskProgress() { var tasks = SchedulingManager.GetManager().GetTaskData(); var myTask = tasks.Where(t => t.TaskName == "SitefinityWebApp.MyScheduledTask").FirstOrDefault(); if (myTask != null) { var progress = myTask.Progress; // Use the progress of the task here } } }
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
Foundations of Sitefinity ASP.NET Core Development
The free on-demand video course teaches developers how to use Sitefinity ASP.NET Core and take advantage of its decoupled architecture and modern development model.