TaskCollection Class

Contains all the tasks that are registered within a TaskFolder. This class has no public constructor and can only be accessed via the properties and functions within TaskFolder.

Definition

Namespace: Microsoft.Win32.TaskScheduler
Assembly: Microsoft.Win32.TaskScheduler (in Microsoft.Win32.TaskScheduler.dll) Version: 2.11.1
public sealed class TaskCollection : IEnumerable, 
	IDisposable
Inheritance
Object    TaskCollection
Implements
IEnumerable, IDisposable

Remarks

Potentially breaking change in 1.6.2 and later where under V1 the list previously included the '.job' extension on the task name. This has been removed so that it is consistent with V2.

Example

C#
public class Program
             {
                bool RootFolderHasTask(string taskName)
                {
                   if (TaskService.Instance.RootFolder.Tasks.Count > 0)
                   {
                      return TaskService.Instance.RootFolder.Tasks.Exists(taskName);
                   }
                   return false;
                }

                TaskCollection GetRootTasksStartingWith(string value)
                {
                   var pattern = $"^{Regex.Escape(value)}.*$";
                   return TaskService.Instance.RootFolder.GetTasks(new Regex(pattern));
                }

                public static void Main()
                {
                   foreach (var task in GetRootTasksStartingWith("MyCo"))
                      if (RootFolderHasTask(task.Name))
                         Console.WriteLine(task.Name);
                }
             }

Properties

CountGets the number of registered tasks in the collection.
ItemInt32Gets the specified registered task from the collection.
ItemStringGets the named registered task from the collection.

Methods

DisposeReleases all resources used by this class.
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
ExistsDetermines whether the specified task exists.
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetEnumeratorGets the collection enumerator for the register task collection.
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
ToStringReturns a String that represents this instance.
(Overrides ObjectToString)

See Also