Click or drag to resize
Task Scheduler Managed Class Library

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.
Inheritance Hierarchy
SystemObject
  Microsoft.Win32.TaskSchedulerTaskCollection

Namespace:  Microsoft.Win32.TaskScheduler
Assembly:  Microsoft.Win32.TaskScheduler (in Microsoft.Win32.TaskScheduler.dll) Version: 2.10.1
Syntax
public sealed class TaskCollection : IEnumerable, 
	IDisposable
Request Example View Source

The TaskCollection type exposes the following members.

Properties
Methods
  NameDescription
Public methodDispose
Releases all resources used by this class.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodExists
Determines whether the specified task exists.
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetEnumerator
Gets the collection enumerator for the register task collection.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a String that represents this instance.
(Overrides ObjectToString.)
Top
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.
Examples
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);
                }
             }
See Also